小编Bav*_*van的帖子

在UIPageViewController中使用TextViews的ViewControllers

我试图学习UIPageViewControllers并找到一个我无法解决的问题.这就是我试图做的事情:

  • 脚步:
    1. 我只是在StoryBoard中创建了2个视图控制器和一个页面视图控制器.
    2. 然后,我添加一些代码的文件的所有者PageViewController表现为一个dataSourcedelegate自己.
    3. 当我跑步时,事情运作良好.
    4. 我在第二个视图控制器中添加了一些按钮和文本字段.
    5. 我跑了,运作得很好.
    6. 现在我将文本视图添加到第二个视图控制器并运行.当我尝试在文本视图中写入内容时,页面控件会抖动并移动到第一个视图控制器.

有没有人经历过这个?

@interface AMPageViewController : UIPageViewController <UIPageViewControllerDataSource, UIPageViewControllerDelegate>

@end
Run Code Online (Sandbox Code Playgroud)

实施:

#import "AMPageViewController.h"

@interface AMPageViewController ()
{
    UIViewController *mainController;
    UIViewController* socController;
}
@end

@implementation AMPageViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
                                                             bundle: nil];

    mainController = (UIViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"First"];
    socController = (UIViewController*)[mainStoryboard …
Run Code Online (Sandbox Code Playgroud)

objective-c uitextview uiviewcontroller uipageviewcontroller ios6

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

SpriteKit:如何创建基本物理关节

我想在两个SKPhysicsBodies之间创建简单的关节.但是,他们表现得非常奇怪.我很清楚锚点应该在场景坐标上.请查看附带的源代码.

例如,这是在矩形上附加小方块后如何生成固定关节.

-(void)createFixedJointOnScene:(SKScene*)scene
Run Code Online (Sandbox Code Playgroud)

{

//Adding Rectangle

    SKSpriteNode* backBone = [[SKSpriteNode alloc] initWithColor:[UIColor whiteColor] size:CGSizeMake(20, 200)];
backBone.position = CGPointMake(CGRectGetWidth(self.frame)/2.0, CGRectGetHeight(self.frame)/2.0);
backBone.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:backBone.size];
backBone.physicsBody.categoryBitMask = GFPhysicsCategoryRectangle;
backBone.physicsBody.collisionBitMask = GFPhysicsCategoryWorld;
[scene addChild:backBone];

//Adding Square
SKSpriteNode* head = [[SKSpriteNode alloc] initWithColor:[SKColor grayColor] size:CGSizeMake(40, 40)];
head.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:head.size];
head.position = CGPointMake(backBone.position.x, backBone.position.y-40);
head.physicsBody.categoryBitMask = GFPhysicsCategorySquare;
head.physicsBody.collisionBitMask = GFPhysicsCategoryWorld;
[scene addChild:head];

//Pinning Rectangle and Square
NSLog(@"Head position %@", NSStringFromCGPoint(head.position));
SKPhysicsJointFixed* pin =[SKPhysicsJointFixed jointWithBodyA:backBone.physicsBody bodyB:head.physicsBody anchor:head.position];
[self.physicsWorld addJoint:pin];
Run Code Online (Sandbox Code Playgroud)

}

在此输入图像描述

https://dl.dropboxusercontent.com/u/62559842/PhysicsTest.zip

谢谢.

physics objective-c ios7 sprite-kit skphysicsbody

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

使用NSDataDetector进行NSDate检测

我试图从UNKNOWN格式的NSString中获取NSDate ,所以我写了一个类似下面的函数

-(void)dateFromString:(NSString*)string {

    NSError *error = NULL;
    NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:(NSTextCheckingTypes)NSTextCheckingTypeDate error:&error];

    NSArray *matches = [detector matchesInString:string
                                         options:0
                                           range:NSMakeRange(0, [string length])];

    NSLocale* currentLoc = [NSLocale currentLocale];
    for (NSTextCheckingResult *match in matches) {
        if ([match resultType] == NSTextCheckingTypeDate) {
            NSLog(@"Date : %@", [[match date] descriptionWithLocale:currentLoc]);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

除了一个地方外,它运作良好.

如果我调用

[self dateFromString:@"6/12"];
Run Code Online (Sandbox Code Playgroud)

它打印

日期:2014年6月12日,星期四,澳大利亚东部标准时间下午12:00:00

如果我打电话的话

[self dateFromString:@"13/12"];
Run Code Online (Sandbox Code Playgroud)

它打印

日期:2013年12月13日星期五下午12:00:00澳大利亚东部夏令时间

基本上,我希望函数表现一致.由于我住在澳大利亚,它应该在12月6日返回首次执行.第二次通话结果是正确的.

我在这做错了什么?

objective-c nsdate ios nsregularexpression nsdatadetector

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

UIRefreshControl为"拉起"刷新?

如何将UIRefreshControl添加到UIColloectionView的底部?这意味着当涉及到Scroll up(查看旧数据或其他内容)时它是如何工作的?

objective-c ios uicollectionview uirefreshcontrol

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

如何在XCode 7+故事板中使用NSScrollView?

我从来没有使用过NSScrollView,但是看一下教程,我觉得应该很容易理解.

然而,事实证明它根本不直观.我拉了一个ScrollView.虽然我已启用,但它没有任何滚动条.没有地方可以设置ContentArea或某种类型.和.它里面有一个剪辑视图,剪辑视图里面有另一个视图.您只能在第三个视图中添加视图.

在此输入图像描述

所以我想在里面添加一个Image视图,它根本不起作用.当我跑步时,它没有显示出来.没有.

在此输入图像描述

我究竟做错了什么?

这是项目的DropBox链接

macos xcode storyboard nsscrollview

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