小编mem*_*ons的帖子

你经常使用什么Xcode键盘快捷键?

你经常使用什么Xcode键盘快捷键?

我非常相信尽可能多地使用键盘(它的速度要快得多),我希望其他人可以分享他们使用的一些Xcode快捷方式.

xcode keyboard-shortcuts

211
推荐指数
13
解决办法
7万
查看次数

如何设置一个git项目来使用外部repo子模块?

我想创建一个可以拉入远程仓库的仓库.

例如,假设jQuery为子模块:

git://github.com/jquery/jquery.git
Run Code Online (Sandbox Code Playgroud)

使用jQuery作为子模块创建repo并将我自己的外部添加为远程repo的过程是什么.

一旦设置好,如果我推/拉到我自己的遥控器,外部是否保持完整?

git external github git-submodules

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

如何在github上取消拉取请求?

如何取消github上的pull请求?

更新 接受的答案没有详细说明答案中的步骤,无论如何,github使这个问题变得简单,因为这个问题被问到了,所以这里是以下步骤:

  1. 访问拉取请求页面
  2. 点按"关闭拉取请求按钮"

git github pull-request

134
推荐指数
5
解决办法
13万
查看次数

如何创建UIView反弹动画?

我有一个名为UIView的以下CATransition finalScoreView,它使它从顶部进入屏幕:

CATransition *animation = [CATransition animation];
animation.duration = 0.2;
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromBottom;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

[gameOver.layer addAnimation:animation forKey:@"changeTextTransition"];
[finalScoreView.layer addAnimation:animation forKey:@"changeTextTransition"];
Run Code Online (Sandbox Code Playgroud)

如何使它在它下降后反弹一次然后保持静止?它应该仍然从顶部进入屏幕,但在它关闭时反弹.

任何帮助将不胜感激,谢谢!

iphone animation uikit uiview ios

88
推荐指数
3
解决办法
8万
查看次数

如何防止按钮的背景图像拉伸?

我正在为UIView分配一个UIButtonTypeCustom UIButton,其背景图像小于按钮的框架.图像较小的原因是因为我试图为UIButton添加更多的"目标区域".但是,图像被缩放到帧的完整大小,而不仅仅是图像的大小.

我已经尝试将UIButton和UIButton的imageView contentMode属性设置为"UIViewContentModeScaleAspectFit",但没有运气,图像仍然被拉伸.

有没有办法做我想以编程方式做的事情?

提前致谢!

cocoa-touch uibutton uikit uiimageview ios

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

如何在iPhone模拟器中重置NSUserDefaults数据?

我已经将NSUserDefault数据检索添加到我的应用程序中,这非常好.但是为了进行测试,我想重置我添加到默认数据库的所有数据,以便当用户第一次启动应用程序时,一切都处于状态.

我试着打电话:

[NSUserDefaults resetStandardUserDefaults];

但那没有做任何事情.默认值仍然保存并可以检索.

iphone cocoa-touch nsuserdefaults uikit ios

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

如何在Swift中设置UITableViewCellStyleSubtitle和dequeueReusableCell?

我想要一个UITableView使用的带subtitle式单元格dequeueReusableCellWithIdentifier.

我原来的Objective-C代码是:

static NSString*    reuseIdentifier = @"Cell";
    UITableViewCell*    cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if(!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
    }
Run Code Online (Sandbox Code Playgroud)

UITableViewSO上搜索了几个问题之后,我想在Swift中写这样的话:

    tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: "Cell")

    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
Run Code Online (Sandbox Code Playgroud)

但这并没有让我说我想要一种subtitle风格.所以我尝试了这个:

var cell :UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell")
Run Code Online (Sandbox Code Playgroud)

这给了我一个subtitle细胞,但它不让我dequeueReusableCellWithIdentifier.

我已经研究了一些并看了这个视频教程,但他创建了一个单独subclassUITableViewCell,我认为是不必要的,因为我之前在Obj-C中完成了相同的效果.

有任何想法吗?谢谢.

uitableview ios swift

48
推荐指数
6
解决办法
8万
查看次数

Objective-C:如何从子类访问父属性?

如果我定义了这个类,如何someObject在没有编译器错误的情况下访问子类中的属性?

@interface MyBaseClass
  // someObject property not declared here because I want it to be scoped 
  // protected. Only this class instance and subclass instances should be
  // able to see the someObject property.
@end

// This is a private interface extension...properties declared here
// won't be visible to subclasses. However, I don't see any way to 
// declare protected properties...
@interface MyBaseClass (private)
   @property (nonatomic, readwrite, retain) NSObject *someObject;
@end
Run Code Online (Sandbox Code Playgroud)

@interface MySubclass : MyBaseClass 
@end

@implementation MySubclass …
Run Code Online (Sandbox Code Playgroud)

oop cocoa cocoa-touch objective-c

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

在Xcode故事板中使用可伸缩的图像

我正在使用故事板来布置我的视图控制器,我想为我的按钮使用可伸缩的图像(这样我就不需要生成几个不同大小的图像).

这可以直接在故事板中直接进行,而无需编写任何代码吗?我真的很喜欢将故事板用于所有图形内容的可能性,并保持代码清洁UI的东西,但似乎我无法在这里摆脱它.

如果不可能,你会建议什么呢?

iphone xcode cocoa-touch ios uistoryboard

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

iOS UIButton与UITextAlignmentLeft仍然居中文本?

问题:
一个按钮的设置后titleEdgeInsetUITextAlignmentLeft按钮的标题仍然是中心,不是以左对齐.

细节:
我有一个200px宽的按钮,使用自定义背景,左侧是图像.由于我不希望按钮标题覆盖图像,我使用了标题titleEdgeInset=UIEdgeInsetsMake(0.0, 45.0, 0.0, 0.0);.这应该使标题标签的x位置从45px开始并以200px结束.我还希望按钮的标题与图像左对齐,所以我也设置了textAlignment = UITextAlignmentLeft.但是,标题文本仍然在45px和200px之间居中,而不是左对齐.

为什么?

这是相关的代码:

button.titleEdgeInsets = UIEdgeInsetsMake(0.0, 45.0, 0.0, 0.0);
button.titleLabel.textAlignment = UITextAlignmentLeft;
[button setTitle:@"X"];
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uibutton ios

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