11var TwitterCell = JSB . defineClass ( 'TwitterCell : UITableViewCell' , {
22 initWithStyleReuseIdentifier : function ( style , reuseIdentifier ) {
3+ self . autoresizingMask = ( 1 << 1 | 1 << 4 ) ;
4+
35 self . iconImageView = UIImageView . alloc ( ) . initWithFrame ( { x : 8 , y : 8 , width : 40 , height : 40 } ) ;
46 self . iconImageView . tag = 1 ;
57 self . contentView . addSubview ( self . iconImageView ) ;
68
79 self . usernameLabel = UILabel . new ( ) ;
10+ self . usernameLabel . autoresizingMask = ( 1 << 1 ) ;
811 self . usernameLabel . frame = { x : 56 , y : 2 , width : 254 , height : 18 } ;
912 self . usernameLabel . font = UIFont . systemFontOfSize ( 12 ) ;
1013 self . usernameLabel . textColor = UIColor . lightGrayColor ( ) ;
1114 self . usernameLabel . tag = 2 ;
1215 self . contentView . addSubview ( self . usernameLabel ) ;
1316
1417 self . tweetLabel = UILabel . new ( ) ;
18+ self . tweetLabel . autoresizingMask = ( 1 << 1 | 1 << 4 ) ;
1519 self . tweetLabel . frame = { x : 56 , y : 20 , width : 254 , height : 40 } ;
1620 self . tweetLabel . font = UIFont . systemFontOfSize ( 14 ) ;
1721 self . tweetLabel . textColor = UIColor . blackColor ( ) ;
@@ -28,6 +32,7 @@ var TwitterViewController = JSB.defineClass('TwitterViewController : UITableView
2832 self . timeline = [ ] ;
2933
3034 self . sizeLabel = UILabel . alloc ( ) . initWithFrame ( { x : 0 , y : 0 , width : 268 , height : 0 } ) ;
35+ self . sizeLabel . autoresizingMask = ( 1 << 1 | 1 << 4 ) ;
3136 self . sizeLabel . font = UIFont . systemFontOfSize ( 14 ) ;
3237 self . sizeLabel . numberOfLines = - 1 ;
3338
@@ -84,11 +89,8 @@ var TwitterViewController = JSB.defineClass('TwitterViewController : UITableView
8489 }
8590 } ) ;
8691 } ,
87- shouldAutorotate : function ( ) {
88- return false ;
89- } ,
90- supportedInterfaceOrientations : function ( ) {
91- return 1 << 1 ;
92+ didRotateFromInterfaceOrientation : function ( fromInterfaceOrientation ) {
93+ self . tableView . reloadData ( ) ;
9294 } ,
9395 numberOfSectionsInTableView : function ( tableView ) {
9496 return 1 ;
@@ -100,7 +102,7 @@ var TwitterViewController = JSB.defineClass('TwitterViewController : UITableView
100102 var tweet = self . timeline [ indexPath . row ] ;
101103
102104 self . sizeLabel . text = tweet [ 'text' ] ;
103- var size = self . sizeLabel . sizeThatFits ( { width : 254 , height : 0 } ) ;
105+ var size = self . sizeLabel . sizeThatFits ( { width : tableView . bounds . width - 66 , height : 0 } ) ;
104106
105107 return Math . max ( size . height + 24 , 80 ) ;
106108 } ,
@@ -116,7 +118,7 @@ var TwitterViewController = JSB.defineClass('TwitterViewController : UITableView
116118 var tweetLabel = cell . contentView . viewWithTag ( 3 ) ;
117119 tweetLabel . text = tweet [ 'text' ] ;
118120 var frame = tweetLabel . frame ;
119- frame . width = 254 ;
121+ frame . width = tableView . bounds . width - 66 ;
120122 tweetLabel . frame = frame ;
121123 tweetLabel . sizeToFit ( ) ;
122124
0 commit comments