在调用popToRootViewControllerAnimated方法之前,将数据发送回根视图控制器的最佳方法是什么?我试图向rootviewcontroller发出信号,表示当前的viewcontroller不再存在,并记录了通过segue推送了什么viewcontroller.
我已经使用autolayout几个星期了.目前,我正在使用名为FLKAutoLayout的第三方库,这使得该过程更容易.我正处于可以按照我想要的方式构建视图的地步,通常没有问题.然而,在过去4天的工作中,一旦参与了控制器,我就一直在努力进行自动布局.我对各种各样的UIViews很好......但出于某种原因,每个viewcontroller.view都是一个完全的恶魔.我只得到一个问题,让viewcontroller.view以我想要的方式调整大小,而更深层次的问题是,当使用autolayout时,子视图控制器的UIViews没有正确接收事件.子视图控制器在手动指定帧时工作得很好,但是一切都因autolayout而崩溃.
我不明白viewcontroller的UIView有什么不同之处让它与其他所有人不同......我的思绪正在沮丧地融化.ios是否在幕后或其他东西搞乱了我的viewcontroller视图?
示例图片http://i39.tinypic.com/6qeh3r.png
在图像中,红色区域属于子视图控制器.这个区域不应该超过最底部的子视图(表示三个的卡).这应该很简单,我可以通过一堆普通的UIViews使它工作得很好但是因为这是一个viewcontroller,一切都会破坏......
任何人都可以阐明我不知道的是什么.任何潜在问题的线索都非常感谢.
谢谢阅读.
更新:问题可能与模棱两可的约束有关
UIView *box = [[UIView alloc]init];
[box addSubview:imageView];
[box addSubview:nameLabel];
imageView constrainWidth:@"32" height:@"32"];
[imageView alignTop:@">=0" leading:@"0" bottom:@"<=0" trailing:@"<=0" toView:box];
[imageView alignCenterYWithView:box predicate:@"0"];
[nameLabel constrainLeadingSpaceToView:imageView predicate:@"5"];
[nameLabel alignTop:@">=0" leading:@">=0" bottom:@"<=0" trailing:@"<=0" toView:box];
[nameLabel alignCenterYWithView:box predicate:@"0"];
[self addSubview:box];
[box alignTop:@"5" leading:@"5" bottom:@"-5" trailing:@"-5" toView:self];
Run Code Online (Sandbox Code Playgroud)
上面的例子是一个模棱两可的布局,但我无法弄清楚它有什么问题......
viewcontroller ios autolayout childviewcontroller flkautolayout
我无法找到带有View Controllers的PageViewController的工作示例作为页面.
我只需要两个水平视图控制器:viewcontroller1和viewcontroller2.
这是我的viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationVertical options:nil];
self.pageController.dataSource = self;
[[self.pageController view] setFrame:[[self view] bounds]];
storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
controller1 = [storyboard instantiateViewControllerWithIdentifier:@"first"];
controller2 = [storyboard instantiateViewControllerWithIdentifier:@"second"];
viewControllers = [NSArray arrayWithObjects:controller1, nil];
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
return controller1;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
return controller2;
}
Run Code Online (Sandbox Code Playgroud)
问题是,在滑动第二个视图后,它会消失.一些帮助理解PageViewController会非常好.
提前致谢
#import "levelSelectorController.h"
#import "ViewController.h"
ViewController *viewController;
@interface levelSelectorController ()
@end
@implementation levelSelectorController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
viewController = [[ViewController alloc] initWithNib:@"ViewController" bundle:nil];
}
@end
Run Code Online (Sandbox Code Playgroud)
这里发生错误:
viewController = [[ViewController alloc] initWithNib:@"ViewController" bundle:nil];
Run Code Online (Sandbox Code Playgroud)
我已经尝试了一些我在stackoverflow上读到的不同的东西,我理解错误应该是什么意思.但我仍然无法解决问题.
是否有可能从一个ViewController?我正在尝试使用商店中的按钮动态填充工具栏,但我不确定如何从控制器访问商店.任何提示赞赏.我的Extjs版本是5.1.
视图:
Ext.define('EurocampingsCMS.view.Foo', {
extend: 'Ext.toolbar.Toolbar',
alias: 'widget.foo',
requires: [
'EurocampingsCMS.controller.Foo'
],
controller: 'foo',
});
Run Code Online (Sandbox Code Playgroud)
视图控制器:
Ext.define('MyApp.controller.Foo', {
extend: 'Ext.app.ViewController',
alias: 'controller.foo',
control: {
'#': {
beforerender: 'onBeforeRender'
}
},
onBeforeRender: function (toolbar, eOpts) {
//How to get store here??
store.each(function (record) {
toolbar.add({
xtype: 'button',
itemId: record.get('localeId'),
text: record.get('label')
});
});
}
});
Run Code Online (Sandbox Code Playgroud) 使用以下代码使视图模糊的背景不能始终如一地工作.
func makeBackgroundBlurry () {
var blurEffect = UIBlurEffect()
blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds //view is self.view in a UIViewController
view.insertSubview(blurEffectView, atIndex: 0)
view.backgroundColor = UIColor.clearColor()
//add auto layout constraints so that the blur fills the screen upon rotating device
blurEffectView.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: blurEffectView, attribute: NSLayoutAttribute.Leading, …Run Code Online (Sandbox Code Playgroud) 如果可能的话,我想控制自己从A到Z可见的场景.
我是iOS的新手,但决定使用故事板,因为它似乎是事情的方向.
从我自己的角度来看,我将把它视为在一个地方设计多个场景的工具,但我想用我自己的代码控制转换.(我正在移植另一种已经管理和跟踪逻辑流程本身的语言和工具)
这引出了我的问题 - 我宁愿在启动时自己加载/选择我的第一个/主要场景并自己"启动"它.我该如何做到最好?
我试图将一个简单的字符串从Swift控制器传递给Objective-C控制器,但不幸的是它不起作用.
我得到的错误:
'EUIDViewController'类型的值没有成员'stringPassed'
Swift Code发送字符串
let pvc = EUIDViewController(nibName: "ScannerViewController", bundle: nil)
if isHasCameraPermission {
pvc.stringPassed = "test"
present(pvc, animated: true, completion: { _ in })
}
Run Code Online (Sandbox Code Playgroud)
Objective-C代码接收字符串
@property (strong, nonatomic) NSString* stringPassed;
- (void)viewDidLoad {
[super viewDidLoad];
[self initOCR];
NSLog(@"String: %@", self.stringPassed);
}
Run Code Online (Sandbox Code Playgroud)
更新:我将#import"EUIDViewController.h"添加到了bridging-header中
我尝试profileView从第一个视图访问视图中的文本字段内容,viewController但是它不起作用。我读到我必须使用,override func prepare(for segue: UIStoryboardSegue, sender: Any?) {}所以我使用了它,但是它仍然无法正常工作,我也不知道为什么。
这是我的viewController代码:
// This code is the code generated by xCode, only the loginField was added.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var loginField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的profileController准备功能: …
I am showing a custom pop up over my main viewcontroller. For this I have created a viewcontroller in the storyboard (image shown), the corresponding class being as below.
class PopUpViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.black.withAlphaComponent(0.7)
self.showAnimate()
}
func showAnimate()
{
self.view.alpha = 1.0
}
func removeAnimate()
{
UIView.animate(withDuration: 0.0, animations: {
self.view.alpha = 0.0;
}, completion:{(finished : Bool) in
if (finished) {
self.view.removeFromSuperview()
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
Then in my main viewcontroller, I show …
viewcontroller ×10
ios ×6
swift ×5
objective-c ×3
autolayout ×1
background ×1
bundle ×1
extjs ×1
javascript ×1
scene ×1
storyboard ×1
string ×1
textfield ×1
uiblureffect ×1
view ×1