小编Mik*_*e V的帖子

UIlabel layer.cornerRadius在iOS 7.1中不起作用

我目前正在寻找具有属性的UILabel addMessageLabel.layer.cornerRadius = 5.0f;在安装了iOS 7.0的设备上,它有圆角.在安装了iOS 7.1的设备上,它没有圆角.

这只是iOS 7.1的一个错误吗?

cornerradius uiview uilabel ios ios7

181
推荐指数
4
解决办法
7万
查看次数

didReceiveRemoteNotification:fetchCompletionHandler:从图标vs推送通知打开

我正在尝试实现后台推送通知处理,但是我在确定用户是否从发送的推送通知中打开应用程序时遇到了问题,而不是从图标打开它.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

    //************************************************************
    // I only want this called if the user opened from swiping the push notification. 
    // Otherwise I just want to update the local model
    //************************************************************
    if(applicationState != UIApplicationStateActive) {
        MPOOpenViewController *openVc = [[MPOOpenViewController alloc] init];
        [self.navigationController pushViewController:openVc animated:NO];
    } else {
        ///Update local model
    }

    completionHandler(UIBackgroundFetchResultNewData);
}
Run Code Online (Sandbox Code Playgroud)

使用此代码,无论用户如何打开应用程序,应用程序都会打开MPOOpenViewController.我怎样才能使视图控制器只有在他们通过刷通知打开应用程序时才会被推送?

使用相同的代码,这适用于iOS 6,但使用新的iOS 7方法,它的行为并不像我想要的那样.

编辑:我正在尝试在iOS 7上运行应用程序,我们不支持iOS 7之前的任何版本.我在方法的iOS 6版本中使用了相同的确切代码(没有完成处理程序)并且它表现得很好我希望它的方式.你要刷通知,这将被调用.如果从图标打开,则永远不会调用该方法.

push-notification apple-push-notifications uiapplicationdelegate ios ios7

50
推荐指数
3
解决办法
4万
查看次数

如何使UIPageViewController半圆形的底部条形图?

我正在制作教程,我正在尝试模仿Path教程的样式,如下所示:

http://www.appcoda.com/wp-content/uploads/2013/06/UIPageViewController-Tutorial-Screen.jpg 在此输入图像描述

我的问题是,如果设置委托方法如此:

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
    // The number of items reflected in the page indicator.
    return 5;
}
Run Code Online (Sandbox Code Playgroud)

然后我在点下面得到这个愚蠢的黑条:

http://i.stack.imgur.com/pUEdh.png 在此输入图像描述

有没有办法让这个酒吧半透明的方式类似于将UINavigationBar设置为半透明?

iphone ios uipageviewcontroller

43
推荐指数
4
解决办法
3万
查看次数

在状态栏iOS 7上方添加UIView横幅

我正在尝试在收到应用内推送通知时在状态栏上方添加横幅.从我一直在阅读的内容看来,动态更改iOS 7中状态栏样式的唯一方法是设置UIViewControllerBasedStatusBarAppearanceNO.这不仅是真的很烦不得不改变我的所有不同的视图控制器prefersStatusBarHidden[UIApplication sharedApplication].statusBarHidden,但它也没有给我找的效果.

当横幅从顶部滑动时,我仍然希望状态栏提供的20个空间保留,但状态栏内容将消失,直到横幅向后滑动.有没有办法做到这一点或在状态栏上方添加子视图或窗口?

基本上我想要这样做:

Facebook Messenger推横幅

objective-c ios ios7 ios7-statusbar

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

"启用严格检查objc_msgSend呼叫"究竟是什么意思?

这就是我所说的:
在此输入图像描述

从我读过的内容来看,objc_msgSend当你发送一个Objective-C消息时,本质上是在c级发生的事情,并且这个设置被设置为Yes确保发送的消息具有与接收者期望的相同数量的参数.

它是否正确?也有什么优点和缺点,以将其设置为YesNo?我应该只Yes在开发和No生产中设置它吗?

xcode objective-c

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

与MongoDB有很多很多关系

我已经看过很多关于如何与MongoDB建立多对多关系的帖子,但没有一个提到规模.例如这些帖子:

MongoDB多对多关联

如何在MongoDB中组织多对多的关系

我可以通过这种设置看到的问题是MongoDB的16MB文档限制.说我有users,groups和posts.posts有一个相关的group和许多user可以喜欢它的s.A中group有很多posts,很多user都可以遵循它.A user可以有许多喜欢post的,可以跟随很多groups.如果我用关系数据库构建它,我会这样设置:

user:
    user_id
    username

post:
    post_id
    group_id
    message

group:
    group_id
    name

post_likes:
    post_id
    liked_user_id

group_followers:
    group_id
    follower_user_id
Run Code Online (Sandbox Code Playgroud)

从理论上讲,a group可以有一个极小数量的posts和users,a post可以拥有无​​限数量的喜欢users,并且如果在SQL查询中正确完成分页,则user可以拥有无​​限数量的喜欢posts和groups .

如何设置MongoDB的模式以便实现这种规模?

mongodb

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

在Parse Framework Cloud Code中运行同步查询

我为Parse Framework编写了一个异步云后台作业,根据"@"符号之前的电子邮件为每个用户生成一个显示用户名.不幸的是,当我运行这份工作时,我收到的错误是"计算操作太多".有没有办法让查询和保存串联运行而不是并行运行?我在文档中看到了promises的可能性,但我对如何使它与嵌套查询一起工作感到困惑.

Parse.Cloud.job("generateUsernameForEveryUser", function(request, status) {

  // Set up to modify user data
  Parse.Cloud.useMasterKey();
  var counter = 0;
  // Query for all users
  var query = new Parse.Query(Parse.User);
  query.each(function(user) {

    createUsernameForUser(user, 0, {
      success: function(username) {
        if(username == null) {
          status.error();
        } else {
          user.set("displayUsername", username);
          user.set("displayUsernameUppercase", username.toUpperCase());
          user.save();
        }
      },
      error: function(error) {
        status.error("Error: " + error.message);
      }         

    });

  }).then(function() {
    // Set the job's success status
    status.success("Username generation completed successfully.");
  }, function(error) {
    // Set the job's error …
Run Code Online (Sandbox Code Playgroud)

javascript parse-platform

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

如何在Xcode中获取当前计算机的IP地址

在测试连接到本地计算机服务器的iPhone应用程序时,我需要输入计算机的本地IP地址,而localhost不是使用模拟器以外的设备进行测试.这会让动态IP地址和多个开发人员进行测试时变得烦人.是否有代码片段可以获取正在编译代码的计算机的IP地址,而不是IP运行应用程序的设备的地址(最好是C或Objective-C,而不是Swift)?

xcode objective-c

5
推荐指数
3
解决办法
3464
查看次数

在GoogleService-info.plist中构建设置用户定义的设置

我有以下GoogleService-info.plist文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>TRACKING_ID</key>
    <string>$(GA_tracking_id)</string>
    <key>PLIST_VERSION</key>
    <string>1</string>
    <key>BUNDLE_ID</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

我的部分构建设置如下所示:

在此输入图像描述

但是,当我记录Google Analytics时,该变量不会取消引用:

VERBOSE: GoogleAnalytics 3.13 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:517): Saved hit: {
    parameters =     {
        "&av" = "1.0.0";
        "&dm" = "x86_64";
        "&ds" = app;
        "&sr" = 640x1136;
        "&t" = screenview;
        "&tid" = "$(GA_tracking_id)";
        "&ul" = "en-us";
        "&v" = 1;
        gaiVersion = "3.13";
    };
    timestamp = "2015-11-04 17:38:54 +0000";
}
Run Code Online (Sandbox Code Playgroud)

我在Fabric中使用了这个策略,但那是在我的Info.plist文件中.此外,$(PRODUCT_BUNDLE_IDENTIFIER)工作如预期.如何将变量取消引用而不是打印出它的文字字符串值.

google-analytics objective-c ios

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

ImportError:安装后没有名为psycopg2的模块

我已经在我的ubuntu服务器上sudo pip install psycopg2成功运行了virtualenv.

这是我正在尝试运行的代码:

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://USERNAME:PASSWORD@localhost/mydb"
db = SQLAlchemy(app)
app.debug = True

class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String(100))

@app.route('/users/', methods = ['GET'])
def users():
    query = "SELECT id, name FROM users"

    results = User.query.from_statement(query).all()

    json_results = []
    for result in results:
        d = {'id' : result.id,
            'name' : result.name}
        json_results.append(d)

    res = jsonify(items=json_results)
    res.headers['Access-Control-Allow-Origin'] = …
Run Code Online (Sandbox Code Playgroud)

python flask uwsgi

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

在iOS 7上使用UIBarButtonItem外观的EXC_BAD_ACCESSWhenContainedIn

//Set all cancel buttons in search bars to "Done"
id searchBarButton = [UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil];
if([[[UIDevice currentDevice] systemVersion] floatValue] < 7) {
    [searchBarButton setTitle:@"Done"];
} else {
    //Can't do anything here or i get EXC_BAD_ACCESS
}
Run Code Online (Sandbox Code Playgroud)

viewDidLoad仅在iOS 7 Gold Master和更新版本上调用时,才会显示EXC_BAD_ACCESS .iOS 7 beta 6及更早版本很好.

在iOS 7中有不同的方法吗?

NSLog("%@", searchBarButton) 结果在iOS7上:

2013-10-01 16:14:25.972 MP Staging[12293:a0b] <_UIBarItemAppearance:0x1aaf72d0> <Customizable class: UIBarButtonItem> when contained in ( UISearchBar ) with invocations (null)>

这在iOS 6上

<_UIBarItemAppearance: 0x1c671aa0>

exc-bad-access uisearchbar ios ios7

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

indexOf(" - ")每次返回-1

var shortLocString = locationString;
console.log("Index of dash in '" + shortLocString + "': " + shortLocString.indexOf('-'));
Run Code Online (Sandbox Code Playgroud)

每次打印这个:

Index of dash in '325–333 Avenue C, New York, NY': -1
Run Code Online (Sandbox Code Playgroud)

为什么我觉得这是一个愚蠢的事情,我在漫长的一天结束时失踪了?

谢谢您的帮助!

麦克风

javascript string parse-platform

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