我想添加一个文本字段和发送按钮,该按钮粘贴在 uitableview 的底部,类似于聊天应用程序。我遇到过关于将 UITableView 作为容器视图嵌入到 UIViewController 中的评论。
然而,他们似乎缺乏如何实现这一目标的例子。更具体的细节包括在哪里添加文本字段/按钮以及在键盘出现时向上移动文本字段等。谢谢!
我在另一个视图控制器(A)上展示了一个视图控制器(B),我希望 B 的背景是透明的,以便 A 在背景中仍然可见。
因此,在呈现B之前,将其modalPresentationStyle设置为.overCurrentContext并且B具有view.backgroundColor = UIColor.clear,以便呈现透明背景。
但是,当我关闭 B 并返回到 A 时,A 的方法(如viewDidAppear、viewWillAppear等)不会重新触发。
如果我将上面的内容更改modalPresentationStyle为.fullScreenviewWillAppear那么当返回到 A 时将会重新触发,但这一次,我失去了透明背景。
总而言之,如何在所呈现的视图上实现透明背景并在viewDidAppear返回 A 时重新触发方法(例如在 A 上)?
在我的项目中,我想在第一次启动应用程序时显示第一个运行视图.为此,我在我的mainViewCntroller.m中添加了一个UIView.为了忽略这个(重叠)视图,我在视图上放了一个名为acceptButton的按钮.我必须添加什么代码才能从堆栈中删除此视图?
我做错了什么?
这是我的代码:
- (void) firstRun {
if (((AppDelegate*)[UIApplication sharedApplication].delegate).firstRun)
{
CGFloat height = [[UIScreen mainScreen] bounds].size.height;
CGFloat width = [[UIScreen mainScreen] bounds].size.width;
NSLog(@"%f", height);
CGRect myFrame = CGRectMake(0, 0, width, height);
UIView *myView = [[UIView alloc] initWithFrame:myFrame];
myView.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
myView.tag = 12345;
[self.view addSubview:myView];
// Create a ScrollView and a label
UIScrollView *discScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(20.0f, 0.0f, self.view.frame.size.width - 20, self.view.frame.size.height -70)];
discScroll.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
UILabel *discLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];
discLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth …Run Code Online (Sandbox Code Playgroud) 如何以有效的方式以编程方式在视图控制器之间切换?我目前正在使用:
ViewController *viewController = [[ViewController alloc] init];
[self presentViewController:viewController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
但是,这不显示我使用界面构建器插入的项目.只有我以编程方式插入的项目.
我希望这样做,因为我想在每个页面上显示一个主页按钮.
我正在尝试使用imagePickerController拍照并在另一个ViewController中的UIImageView中显示图像.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:NULL];
PAWWallPostCreateViewController *wallPostCreateViewController = [[PAWWallPostCreateViewController alloc] initWithNibName:@"PAWWallPostCreateViewController" bundle:nil];
wallPostCreateViewController.myImage = info[UIImagePickerControllerEditedImage];
wallPostCreateViewController.imageView = [[UIImageView alloc] initWithImage:wallPostCreateViewController.myImage];
wallPostCreateViewController.imageView.contentMode = UIViewContentModeScaleAspectFit;
NSLog(@"%@",wallPostCreateViewController.imageView); // Output below
[self.navigationController presentViewController:wallPostCreateViewController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
NSLog中imageView的输出是:
<UIImageView: 0x18f695b0; frame = (0 0; 640 640); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x18f14240>>
Run Code Online (Sandbox Code Playgroud)
框架对我的实际UIImageView来说太大了,它被设置为(60 227; 200 200)
我认为这就是我运行应用程序时根本无法看到UIImageView的原因.我该如何解决?
编辑:
在PAWWallPostCreateViewController.h中
@property (nonatomic, strong) IBOutlet UIImageView *imageView;
Run Code Online (Sandbox Code Playgroud)
我将imageView链接到我的.xib文件
熟悉autoresize = RM + BM的人也是; 因为通常当我使用imagePickerController将UIImage放在同一个视图控制器的UIImageView中时,我的UIImageView数据有一个autoresize = RM + BM; …
view和viewcontroller是分开的.我已经尝试过NSUserDefaults它不起作用了.
[[NSUserDefaults standardUserDefaults] setValue:BOOLCondition forKey:@"YES"];
[[NSUserDefaults standardUserDefaults] synchronize];
Run Code Online (Sandbox Code Playgroud)
它表示bool到id的影响转换不允许使用arc
如何传递bool值
*****查看viewcontroller而不是viewcontroller到viewcontroller
我在.xib文件中有一个按钮.
我希望如果我点击那个按钮.应该改变viewController的.xib文件颜色.
我怎样才能做到这一点?
我应该使用NSNotification还是有其他方法可以做到这一点?
从我的appdelegate我需要执行一个来自viewcontroller的方法.
请问,有人能告诉我如何轻松地从appdelegate调用我需要的任何方法吗?
关于这个论点的很多问题但是没有一个是有用/完整/正确的,所以请避免将URL发布到其他主题:我已经检查了所有问题,但我真的找不到关于在Swift中这样做的任何确切答案.:)
当我点击图片下方屏幕右侧的3个点时,我正在努力实现类似Instagram的功能.这是点击点之前的样子:
以下是它的样子:
显然我的滚动图片是一个UITableView,但我的问题是,当我点击3个点并且它带有一个选项列表的第二个视图时,这是另一个UITableView,还是你认为他们只是提出一个UIView的?
在这样的场景中使用的最佳选择是什么?

如您所见,屏幕流程如下:
点击"屏幕A"的"按钮2"后,应用程序会在同一个具有标签栏的故事板中显示"屏幕B".点击"屏幕B"的"红色标签"后,应用程序会显示"绿色按钮"(右上角).点击"屏幕B"的"绿色按钮"后,应用程序会显示"故事板2"的"屏幕C".
点击"屏幕C"的后退按钮后,我需要回到"故事板1"的"屏幕B",无论"屏幕C"出现在哪里,"故事板2"的"屏幕C"应该消失从上到下.
是否有可能这样做,如果是,那么如何?
在viewDidLoadUIViewController 的方法内:
NSLog(@"frame: %f %f", self.view.frame.size.width, self.view.frame.size.height);
Run Code Online (Sandbox Code Playgroud)
使用横向设备:
frame: 748.000000 1024.000000
Run Code Online (Sandbox Code Playgroud)
设备处于纵向状态:
frame: 768.000000 1004.000000
Run Code Online (Sandbox Code Playgroud) 我有一个带有 4 个 vc 的导航控制器:
navigationController
FirstController
SecondController
ThirdController
FourthController
Run Code Online (Sandbox Code Playgroud)
当我在的时候,FirstController我想打印出所有没有被压入堆栈的子 vcs 的列表。
我试过:
let allVCs = self.navigationController!.childViewControllers
print(allVCs.description)
Run Code Online (Sandbox Code Playgroud)
我也试过:
let allVCs = self.navigationController!.viewControllers
print(allVCs.description)
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,我都只得到ProjectName.FirstController. 我意识到我明白了,因为这是目前堆栈中唯一的一个。
即使它们尚未被推入堆栈,我如何找出其余的子 vcs?
//print statements I'm looking to get
ProjectName.FirstController
ProjectName.SecondController
ProjectName.ThirdController
ProjectName.FourthController
Run Code Online (Sandbox Code Playgroud) uiviewcontroller uinavigationcontroller ios childviewcontroller swift
我怎么比较viewDidLoad和viewDidAppear:
uiviewcontroller ×13
ios ×12
swift ×6
objective-c ×5
uitableview ×2
uiview ×2
xcode ×2
appdelegate ×1
cocoa-touch ×1
frame ×1
iphone ×1
lifecycle ×1
segue ×1
swift2 ×1
uiimageview ×1
xcode6.3 ×1
xib ×1