iOS:我的tableView没有显示出来

时间:2014-10-08 11:06:41

标签: ios objective-c iphone uitableview

我的iOS应用程序存在问题。这是一个简单的iOS网络浏览器。

我的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课程

我将不胜感激任何建议。提前谢谢。

1 个答案:

答案 0 :(得分:-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;