小编Bor*_*kyi的帖子

是否有必要在viewWillAppear中调用super?

我试图了解方法调用方案的场景,确实/将会出现和消失.

我所做的是选择表格单元格(灰色高光),转到详细视图并返回并取消选择所选行(删除选定的单元格灰色).

这是我的方法:

-(void)viewDidAppear:(BOOL)animated {
    DLog(@"%@ did appear", self);
    [super viewDidAppear:animated];

    if (_isPushed) {
        [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
        _isPushed=NO;
    }
}

-(void)viewWillAppear:(BOOL)animated {
    DLog(@"%@ will appear", self);
    [super viewWillAppear:animated];  //If I remove this super call , then it works fine and there is no delay in deselecting the table cell
}

-(void)viewWillDisappear:(BOOL)animated {
    DLog(@"%@ will disappear", self);
    [super viewWillDisappear:animated];
}

-(void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    _isPushed=YES;
}
Run Code Online (Sandbox Code Playgroud)

所以,当我放断点时,流程如下:

没有超级电话:

在推动新VC的同时:

current viewWillDisappear    //makes sense
new viewWillAppear           //makes sense
current viewDidAppear         // …
Run Code Online (Sandbox Code Playgroud)

objective-c viewdidappear viewwillappear ios

2
推荐指数
1
解决办法
1627
查看次数

基于iOS的项目实现MVC vs MVVM与VIPER的真实场景

任何人都可以解释为基于iOS的项目实现MVC vs MVVM与VIPER的真实场景.我正在寻找一些解释我们应该在哪里使用MVC,MVVM和VIPER的示例.

提前致谢.

model-view-controller mvvm cocoa-design-patterns ios viper-architecture

2
推荐指数
1
解决办法
4373
查看次数

LSApplicationQueriesSchemes和派生数据

我想在我的应用程序中打开一个whatsapp url.

let whatsAppUrl = NSURL(string: "whatsapp://send?text=Hello%2C%20World!")
if UIApplication.sharedApplication().canOpenURL(whatsAppUrl!) {
    UIApplication.sharedApplication().openURL(whatsAppUrl!)
}
Run Code Online (Sandbox Code Playgroud)

我使用字典"LSApplicationQueriesSchemes"扩展我的info.plist并为whatsapp添加我的url方案.

<key>LSApplicationQueriesSchemes</key>
<dict>
    <key>Item 0</key>
    <string>whatsapp</string>
</dict>
Run Code Online (Sandbox Code Playgroud)

如果我运行我的应用程序,我收到以下错误消息.

"This app is not allowed to query for scheme whatsapp"
Run Code Online (Sandbox Code Playgroud)

我阅读了一些清理派生数据的解决方案并再次运行应用程序以解决此问题.但这对我没有帮助,对我的问题存在另一种解决方案吗?

swift

2
推荐指数
2
解决办法
5461
查看次数

WKWebView中的javascript桥不起作用

我尝试使用从Web视图中获取javascript消息WKWebView。但是IOS控制台内部什么也没有出现...

我实现以下代码:

- (void) webView:(WKWebView *)webView didFailLoadWithError:(NSError *)error {
    self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height-20)];
    self.webView.backgroundColor = [UIColor whiteColor];

    self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

    self.webView.scrollView.delegate = self;
    [self.view addSubview:self.webView];

    // Setup WKUserContentController instance for injecting user script

    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc]
         init];

    WKUserContentController* userController = [[WKUserContentController alloc]init];

    [userController addScriptMessageHandler: self name:@"notification"];
    configuration.userContentController = userController;

    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/test.php"]]];
}

- (void)userContentController:(WKUserContentController*)userContentController
      didReceiveScriptMessage:(WKScriptMessage*)message {
    NSLog(@"%@", message.body);
}
Run Code Online (Sandbox Code Playgroud)

和HTML / JS:

<div id="test" onclick="test();">test</div>

<script type="text/javascript" src="jquery.js"></script> …
Run Code Online (Sandbox Code Playgroud)

javascript objective-c wkwebview

1
推荐指数
1
解决办法
1615
查看次数