小编thi*_*sai的帖子

自iOS6以来UINavigationBar中的标题未对齐

从iOS 6开始,我在应用程序中使用自定义样式时遇到了一些问题.我使用自定义字体和几个UIAppearance代理.我无法理解的一个问题是UINavigationBar中标题的错位.在iOS 5中,一切正常,并且正确对齐.

由于iOS6已经发布并且自定义样式并不少见,我认为这不是一个bug,而是我对iOS6的一些新变化的误解.

错位

我在文档中搜索了一个文本对齐方法来调用UIAppearance代理,但我无法找到这样的方法.

我使用以下代码行来为我的整个应用程序设置UINavigationBar的样式:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"] 
                                   forBarMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"] 
                                   forBarMetrics:UIBarMetricsLandscapePhone];

[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor whiteColor], UITextAttributeTextColor, 
                                                      [UIFont fontWithName:@"Corbel-Bold" size:14.0], UITextAttributeFont,
                                                      nil]];


[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTintColor:[UIColor whiteColor]];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                      [UIColor ceBlueColor], UITextAttributeTextColor,
                                                      [UIColor whiteColor], UITextAttributeTextShadowColor, 
                                                      [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, 
                                                      [UIFont fontWithName:@"Corbel" size:0.0], UITextAttributeFont, 
                                                      nil]
                                            forState:UIControlStateNormal];

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -3) forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

fonts uinavigationbar ios uiappearance

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

在Laravel 4迁移中添加MySQL地理空间Point列

  1. 如何在我的Laravel 4迁移中为MySQL数据库添加一个Point列?
  2. 是否可以使用检查mysql并检查postgres语句来设置数据库无关的迁移?如果是这样我怎么能这样做呢?

我试过了:

public function up()
{
    Schema::create('meetings', function(Blueprint $table) {
        $table->increments('id');

        $table->string('title');
        $table->text('description');
        $table->enum('category',[0,1,2,3,4])->index();

        $table->unsignedInteger('owner_id');
        $table->foreign('owner_id')->references('id')->on('users')->onDelete('cascade');

        $table->dateTime('start_date');
        $table->dateTime('end_date');

        $table->timestamps();
    });
    DB::raw("ALTER TABLE meetings ADD COLUMN geolocation POINT"); 
}
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用.

mysql geospatial laravel laravel-4

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

使用自动布局对MKAnnotationView进行子类化

我喜欢iOS 6中的新自动布局功能,但是当我将它与MKAnnotationView子类结合使用时,我遇到了一些麻烦.

我在初始化方法中禁用了自动调整掩码转换.

self.translatesAutoresizingMaskIntoConstraints = NO;
Run Code Online (Sandbox Code Playgroud)

但是当我加载使用我的子类的注释的MKMapView时,应用程序抛出NSInternalInconsistencyException.

*** Assertion failure in -[ENMapAnnotationView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. ENMapAnnotationView's implementation of -layoutSubviews needs to call super.'
Run Code Online (Sandbox Code Playgroud)

我没有覆盖-layoutSubviews,所以对我看来,Apple的MKAnnotationView实现还没有为自动布局做好准备.有没有一些聪明的方法来解决MKAnnotationView中缺少自动布局支持所以我可以在我的子类中使用自动布局?

iphone mapkit mkannotationview ios autolayout

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