如何在XOS 4.2上为IOS 5创建UItableVIEw?
obs:我没有使用storyBoard只是XIB的!
解决方法 在.h文件中,添加以下内容:@interface YourClass: UIVIEwController <**UItableVIEwDataSource,UItableVIEwDelegate**>
右键单击(或按住Ctrl键单击)并从tableVIEw拖动到文件所有者两次.一次,选择“委托”,然后选择“dataSource”.
然后,在.m文件中,您需要实现以下内容:
- (NSInteger)numberOfSectionsIntableVIEw:(UItableVIEw *)tableVIEw{return 1;}- (NSInteger)tableVIEw:(UItableVIEw *)tableVIEw numberOfRowsInSection:(NSInteger)section{return someNumber;}- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static Nsstring *CellIDentifIEr = @"Cell"; UItableVIEwCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:CellIDentifIEr]; if (cell == nil) { cell = [[UItableVIEwCell alloc] initWithStyle:UItableVIEwCellStyleDefault reuseIDentifIEr:CellIDentifIEr]; } [[cell textLabel] setText:yourText]; return cell;}- (voID)tableVIEw:(UItableVIEw *)tableVIEw dIDSelectRowAtIndexPath:(NSIndexPath *)indexPath{ //do what you want to with the information at indexPath.row}
这应该会让你找到一个工作表.
总结以上是内存溢出为你收集整理的iphone – 我如何在Xcode 4.2上为IOS 5创建一个UITableView?全部内容,希望文章能够帮你解决iphone – 我如何在Xcode 4.2上为IOS 5创建一个UITableView?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)