![](/img/trans.png)
[英]preferredStatusBarStyle .lightContent doesn't work with Navigation Controller
[英]navigation view doesn't work first click
我有一個導航視圖,當我點擊時,我只顯示行號。
在mainView中:
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (read == nil) {
readNotice *aController = [[readNotice alloc]initWithNibName:@"readNotice" bundle:nil];
self.read = aController;
}
[read updateRowNumber:indexPath.row];
[[self navigationController] pushViewController:read animated:YES];
在我的readNotice
類中:
-(void)updateRowNumber:(int)theindex {
rowNumber = theindex + 1;
message.text = [NSString stringWithFormat:@"row %i was clicked", rowNumber];
NSLog(@"view did load row = %d", rowNumber);
}
readNotice.xib僅包含Label內容。
我第一次點擊它顯示“標簽”,但它可以進行以下嘗試。
我想我需要嘗試一些我錯過的東西,但我找不到它。
先感謝您
我無法理解為什么你做了變量....? 用這個 ..
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
readNotice *aController = [[readNotice alloc]initWithNibName:@"readNotice" bundle:nil];
[self.navigationController pushViewController:aController animated:YES];
[aController updateRowNumber:indexPath.row];
}
這可能會對你有所幫助......
采用 -
if (self.read == nil) {
readNotice *aController = [[readNotice alloc]initWithNibName:@"readNotice" bundle:nil];
self.read = aController;
}
--------
---------
[[self navigationController] pushViewController:self.read animated:YES];
在tableview中嘗試這個:didSelectRowAtIndex方法,
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (read == nil) {
readNotice *aController = [[readNotice alloc]initWithNibName:@"readNotice" bundle:nil];
self.read = aController;
}
read.index = indexPath.row;
[[self navigationController] pushViewController:read animated:YES];
在readNotice
創建一個實例變量as
@property(assign) int index;
@synthesize index;
在readNotice
viewDidLoad方法中,您只需調用updateRowNumber
- (void)viewDidLoad
{
[super viewDidLoad];
[self updateRowNumber:index];
}
它會按預期顯示數字
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.