表视图推送到新视图 XIB

发布于 2024-10-22 11:29:35 字数 615 浏览 1 评论 0原文

我创建了一个表视图,从数组中提取其单元格。

每个单元格都需要推送到不同的视图......并且我找不到被点击的单元格的值。它需要一个条件语句,但没有值我无法推送视图:(

下面是我的 didSelectRowAtIndexPath 的片段

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.

if(){

SendSms *detailViewController = [[SendSms alloc] initWithNibName:@"SendSms" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}

}

您将看到 If 语句为空...我需要推送列的值以推送到另一个视图控制器。

请帮忙!

I have created a table view that pulls its cells from an array.

Each cell needs to push to a different view... and I cannot find the value of the tapped cell. It needs a conditional statement but without the value i cannot push the view :(

below is the snippet of my didSelectRowAtIndexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.

if(){

SendSms *detailViewController = [[SendSms alloc] initWithNibName:@"SendSms" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}

}

You will see the If statement is blank... I need the value of the column pushed to push to another view controller.

Please help! Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

握住我的手 2024-10-29 11:29:35

我将为那些可能正在寻找它的人回答我自己的问题,因为我刚刚解决了:)

使用:

if([InsertYourArrayOfDataHere objectAtIndex:indexPath.row] == @"StringInArray")

希望这可以帮助有同样问题的人

I'll answer my own question for those who may be searching it out since i just worked it out :)

use:

if([InsertYourArrayOfDataHere objectAtIndex:indexPath.row] == @"StringInArray")

Hope that might help someone with the same problem

放赐 2024-10-29 11:29:35

即使在乔纳森的回答之后,我还是建议使用这个,最好使用

if([[InsertYourArrayOfDataHere objectAtIndex:indexPath.row] isEqualToString: @"StringInArray"]) {
//Your Code goes here.
}

如果您正在比较字符串,您应该使用 isEqualToString 方法。

Even after Jonathan's answer I recommend to use this, It would be better to use

if([[InsertYourArrayOfDataHere objectAtIndex:indexPath.row] isEqualToString: @"StringInArray"]) {
//Your Code goes here.
}

If you are comparing string you should use isEqualToString method.

审判长 2024-10-29 11:29:35
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//you willget alldetail of cell here.

if(){

SendSms *detailViewController = [[SendSms alloc] initWithNibName:@"SendSms" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//you willget alldetail of cell here.

if(){

SendSms *detailViewController = [[SendSms alloc] initWithNibName:@"SendSms" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
挽心 2024-10-29 11:29:35

您可以找到被点击的单元格的值,例如

indexpath.row,

当用户触摸任何单元格值时,indexpath.row将为您提供一个数字,然后您可以执行一些操作,例如

if(indexpath.row == 0)

{

//here create the object for the view1 where you want to navigate

//show view 1

}

else 
{

//show view 2

}

希望这能解决您的问题。

you can find the value of the tapped cell like

indexpath.row,

when user will touch any cell values the indexpath.row will provide you a number then you can perform some actions like

if(indexpath.row == 0)

{

//here create the object for the view1 where you want to navigate

//show view 1

}

else 
{

//show view 2

}

Hope this will solve your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文