- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在做一个简单的应用程序,用于查看来自 json 服务器的项目
我在一个 UIViewController 中使用 UISegment 来添加不同的 subview
- (IBAction)segmentSwitch:(id)sender {
UISegmentedControl *segmentedControl = (UISegmentedControl *) sender;
NSInteger selectedSegment = segmentedControl.selectedSegmentIndex;
if (selectedSegment == 0) {
instantiateViewControllerWithIdentifier:@"prestige"] animated:NO];
UIViewController *subController = [self.storyboard instantiateViewControllerWithIdentifier:@"prestige"];
[mainView addSubview:subController.view];
}
else if(selectedSegment == 1)
{
instantiateViewControllerWithIdentifier:@"latest"]];
//[self setView: [self.storyboard instantiateViewControllerWithIdentifier:@"latest"]];
//UIViewController *subController = [self.storyboard instantiateViewControllerWithIdentifier:@"latest"];
//[mainView addSubview:subController.view];
UITableViewController *tableVC =[self.storyboard instantiateViewControllerWithIdentifier:@"latest"];
[self.view addSubview:tableVC.tableView];
}
else if (selectedSegment == 2)
{
instantiateViewControllerWithIdentifier:@"contactUs"]];
UIViewController *subController = [self.storyboard instantiateViewControllerWithIdentifier:@"contactUs"];
[mainView addSubview:subController.view];
}
}
当我选择 select Segment 2 将 uitableviewcontroller 作为 subview 查看时出现错误x 代码给我以下错误
exc_bad_access (code=1 address=0x110ff210 on line NSDictionary *latests = [latestArray objectAtIndex:indexPath.row];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"latestCell1";
latestCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSDictionary *latests = [latestArray objectAtIndex:indexPath.row];
NSString *latest_name_En = [latests objectForKey:@"title_en"];
NSString *logo1 = [latests objectForKey:@"logo"];
NSString *img1 = [latests objectForKey:@"img1"];
NSData *latestsImg1 = [NSData dataWithContentsOfURL:[NSURL URLWithString:img1]];
NSData *latestsLogo1 = [NSData dataWithContentsOfURL:[NSURL URLWithString:logo1]];
cell.latest_name_en1.text = latest_name_En;
dispatch_async(dispatch_get_main_queue(), ^{
cell.latest_img1.image = [UIImage imageWithData:latestsImg1];
cell.latest_logo1.image = [UIImage imageWithData:latestsLogo1];
});
return cell;
}
我确信 UITableViewController 工作正常,因为我尝试单独运行它,它也可以在没有自定义单元的情况下尝试它,它也可以工作,但使用自定义单元作为 subview 时,它会给出上面的错误。
最佳答案
感谢您的帮助
我终于弄清楚我用过
[self addChildViewController:subController];
[mainView addSubview:subController.view];
将 TableView 作为 subview 添加到 View Controller
成功了
关于iphone - 在 uiviewcontroller 中添加 uitableviewcontroller 作为 subview 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10874135/
我正在使用 Swift 制作一个应用程序,但遇到了一个问题:我有一个系统,人们可以在其中发布“帖子”,并对这些“帖子”发表评论。 为了显示这一点,我有一个 UITableViewController
用户点击“远程”按钮,然后加载以下 UITableViewController: 然后用户选择我调用的任何值: [self.navigationController popViewController
在我离开页面并使用 UITabBarController 返回后,我的 TableViewController 在页面顶部留下了一个空隙。在初始加载时它很好,只有当我离开页面然后返回时才会出现间隙。我
我有一个 TableViewController (VC1) 设置为推送到另一个 TableViewController (VC2)。这个连接是通过从 VC1 到 VC2 的 ctrl-drag 在
在我的核心数据模型中,我有一个 Person 实体,它与 Course 实体具有“对多”关系(我还具有从 Course 到 Person 的反向“对一”关系)。 现在我有一个子类化的 UITableV
为什么不调用 numberOfSectionsInTableView 方法?如果我在 viewDidLoad 中添加 [self.tableView reloadData],它就会被调用,但即便如此,
在 UITableViewController 中,我有一个方法可以更新显示总价的底部工具栏。 public override UITableViewCell GetCell(UITa
我正在制作一个 iPad 应用程序,其中包含一个用于设置选项的 View 。这个“选项” View 有两个容器 View ,每个容器 View 都包含一个 TableView,其中包含两种不同的选项,
假设设置是 导航 Controller -> GradLevelUITableViewController -> DegreeUITableViewController -> View Control
我的问题是,这是否可能,如果可能,您将如何完成这项任务? 有人知道已经在使用此功能的应用程序,或者可以从哪里获得一些示例代码吗? 此外,如果我要在对主题了解不多的情况下自行实现此操作,您估计需要多长时
当 UITableViewController 的框架低于特定高度时,UITableViewController refreshControl 会出现问题。 就目前而言,我有一个 UIViewCont
我有我的主视图和一个 RoutinesTableViewController。 我想放松回到我的 VC 并尝试了这个: @IBAction func selectRoutine(segue:UISto
我是 swift 和 Xcode 的新手,我正在尝试一些事情。当我转到设置页面时,我想在设置页面(在应用程序中,而不是在设置 bundle 中)设置开关状态。 (我将segue设置为push)为此,我
我目前正在尝试将不同的实体从我的 CoreData 模型加载到一个 UITableView 中,但位于不同的部分下。我尝试过以下方法: override func tableView(tableVie
我试图让 tableview 适应 Swift 中键盘的显示。根据文档,如果 tableview 是 UITableViewController 的子类,它应该自动调整。已经在这里阅读了很多答案,只是
我想捕获UITableViewController中触摸点的x位置。网上描述的最简单的解决方案是UITapGestureRecognizer:enter link description here 但
我是 iPhone 编程的初学者。我的第一个应用程序是 UITableViewController 但现在我想尝试一下。这个想法是创建一个如下所示的自定义布局: 布局: ---------------
我有一个基于导航的应用程序,我将 UITableViewControllers 推送到堆栈上。我想向我的所有 UITableViewControllers 添加背景 UImage。不是 UIColor
在找到位置后,我尝试在 UITableViewController 中重新加载数据。这也意味着在 viewDidLoad 方法之后。我的类正在使用此接口(interface)扩展 UITableVie
我有一个TabBarController,其中一个选项卡包含一个 subview ,它是一个navigationController。然后,我将继承 UITableViewController 形式的
我是一名优秀的程序员,十分优秀!