我的应用程序结构如下:
UIViewController1
<?php
$feedback = $_POST["feedback"];
echo $feedback;
?>
UIViewController1包含UIViewController2,我添加了一些UIView,从Xib加载到UIViewController2,代码如下:
SessionView* b = [[[NSBundle mainBundle] loadNibNamed:@"SessionView" owner:self options:nil] lastObject]; [self.view addSubview:b]; //- set Frame before or after addSubView, there is no difference CGRect frame = b.frame; frame.origin.x = 0; frame.origin.y = 0; b.frame = frame;
最初的UIView看起来像这样:
添加到UIViewController后,它看起来像这样:
使用下面的代码,当我指定UIView的宽度和高度等于主视图的宽度和高度的一部分时,它看起来不错
SessionView* b = [[[NSBundle mainBundle] loadNibNamed:@"SessionView" owner:self options:nil] lastObject]; [self.view addSubview:b]; CGRect frame = b.frame; frame.origin.x = 0; frame.origin.y = 0; //------- Assign the Width and Height Value //------------------------------------------- frame.size.width = CGRectGetWidth(self.view.bounds) / 3; frame.size.height = CGRectGetHeight(self.view.bounds) / 3; b.frame = frame;
答案 0 :(得分:0)
您似乎直接将viewController
添加为子视图,而应将view
viewController
添加为子视图。
SessionView* b = [[[NSBundle mainBundle] loadNibNamed:@"SessionView" owner:self options:nil] lastObject];
[self.view addSubview:b.view];