2014-10-08 66 views
0

我的iOS应用程序出现问题。这是一个简单的iOS网页浏览器。iOS:我的tableView不显示

我的tableView在Xcode xib中可见,但在运行模拟器时未显示。我已经实现UITableViewDataSourceUITableViewDelegate协议和下面的方法:

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView 

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

-(UITableViewCell *) tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

这里是我的AppDelegate.h class

#import <UIKit/UIKit.h> 

@interface AppDelegate : UIResponder <UIApplicationDelegate> 

@property (strong, nonatomic) UIWindow *window; 

@end 

这里是我AppDelegate.m

这里是我的History&Favorites.h class

#import <UIKit/UIKit.h> 

@interface History_Favorites : UIViewController <UITableViewDataSource, UITableViewDelegate> 
@property (retain, nonatomic) IBOutlet UITableView *tableWithBookmarks; 
@property (retain,nonatomic) NSMutableArray *URLs; 

@end 

这里是我的History&Favorites.m

我将不胜感激任何意见。提前致谢。

+0

这是当我运行的应用程序,没有显示与我的tableView厦门国际银行文件。 http://i.stack.imgur.com/XAR6m.png – Diana 2014-10-08 11:07:27

+1

[self.URLs count]在numberOfRowsInSection中返回的值是否与0不同? – Rafouille 2014-10-08 11:14:25

+0

你可以显示代码如何实现'cellForRowAtIndexPath:' – nburk 2014-10-08 11:17:31

回答

-1

添加以下内容:

@synthesize tableWithBookmarks; 

更新的cellForRowAtIndexPath方法有以下几点:

-(UITableViewCell *) tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *cellIdentifier = @"Cell"; 
UITableViewCell *hiddenCell = [tableWithBookmarks dequeueReusableCellWithIdentifier:cellIdentifier]; 

if (hiddenCell == nil) 
{ 
    hiddenCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]autorelease]; 
} 

hiddenCell.textLabel.text = @"Detail"; 
//[self.URLs objectAtIndex:indexPath.row]; 
//History_Favorites *historyView = [[History_Favorites alloc]init]; 
//[self.navigationController pushViewController:historyView animated:YES]; 

return hiddenCell; 
+0

感谢你和这一行'UITableViewCell * hiddenCell = [tableWithBookmarks dequeueReusableCellWithIdentifier:cellIdentifier];'我在代码中发现了另一个错误。但我的问题仍未解决。 – Diana 2014-10-08 12:59:50

+0

如果我的代码已经帮助了你,请提出答案 – 2014-10-09 03:56:43

+0

对不起,但你的回答没有帮助。问题在于我的班上有'&'符号。无论如何感谢你的贡献。 – Diana 2014-10-09 19:38:10