首页 \ 问答 \ 我在哪里可以找到iPad示例代码[已关闭](Where can I find iPad Sample Code [closed])

我在哪里可以找到iPad示例代码[已关闭](Where can I find iPad Sample Code [closed])

我知道iPhone有一个带有示例应用程序和iPhone代码的站点。 iPad有什么资源吗?

我想要iPad的具体例子,如使用分割视图等。


I know the iPhone has a site with sample apps and code for the iPhone. Are there any resources out there for the iPad?

I would like iPad specific examples like using split view, etc.


原文:https://stackoverflow.com/questions/2276513
更新时间:2023-08-22 22:08

最满意答案

问题在于忘记静态实际上只是普通的C静态变量,它们可以在整个应用程序中全局访问。 (即,未封装在定义它们的范围内。)

同一个类的多个实例都在读取和写入同一个变量的值,从而导致不可预测的行为。

解决方案:传递实例级别消息以控制切换活动,您无法保证您的类是单例。

修改工作代码:

- (void)beginAnimationWithOrgigin:(CGPoint)origin Terminus:(CGPoint)terminus Direction:(NSString*)direction{

    if (!direction)direction = @"FORWARD";

    NSLog (@"Message %@ in context %@",((UILabel*)_textLabel).text,_ctx);

    CGFloat text_width = ((UILabel*)_textLabel).frame.size.width;
    CGFloat display_width = self.frame.size.width;

    if ( text_width > display_width ) {
        float duration = (text_width - display_width)/40;
        [self setContentOffset:origin];

        [UIView beginAnimations:direction context:_ctx];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDelay:1.0];
        [UIView setAnimationDuration:duration];
        [UIView setAnimationRepeatCount:1];
        [self setContentOffset:terminus];

        [UIView commitAnimations];

    }
}



- (void)animationDidStop:(NSString *)animationID
        finished:(NSNumber *)finished
         context:(void *)context
{

    NSLog(@"Animation Did stop context = %@",context);
    NSString *direction;
    CGPoint origin;
    CGPoint terminal_origin;

    if (![animationID isEqualToString:@"FORWARD"]){
        origin = CGPointMake(0, 0);
        terminal_origin = CGPointMake(((UILabel*)_textLabel).frame.size.width - self.frame.size.width, ((UILabel*)_textLabel).frame.origin.y);
        direction = @"FORWARD";
    }else{

        terminal_origin = CGPointMake(0, 0);
        origin = CGPointMake(((UILabel*)_textLabel).frame.size.width - self.frame.size.width, ((UILabel*)_textLabel).frame.origin.y);
        direction = @"BACKWARD";
        }

    [self beginAnimationWithOrgigin:origin Terminus:terminal_origin Direction:direction];
}

The problem was in forgetting that statics really are just ordinary C static variables which are globally accessible across the app. (i.e, not encapsulated in the scope that defined them.)

Multiple instances of the same class are all reading and writing values to a the same variable causing unpredictable behaviour.

Solution: Pass instance level messages to control toggling activities where you can't guarantee your class is a singleton.

Modified Working Code:

- (void)beginAnimationWithOrgigin:(CGPoint)origin Terminus:(CGPoint)terminus Direction:(NSString*)direction{

    if (!direction)direction = @"FORWARD";

    NSLog (@"Message %@ in context %@",((UILabel*)_textLabel).text,_ctx);

    CGFloat text_width = ((UILabel*)_textLabel).frame.size.width;
    CGFloat display_width = self.frame.size.width;

    if ( text_width > display_width ) {
        float duration = (text_width - display_width)/40;
        [self setContentOffset:origin];

        [UIView beginAnimations:direction context:_ctx];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDelay:1.0];
        [UIView setAnimationDuration:duration];
        [UIView setAnimationRepeatCount:1];
        [self setContentOffset:terminus];

        [UIView commitAnimations];

    }
}



- (void)animationDidStop:(NSString *)animationID
        finished:(NSNumber *)finished
         context:(void *)context
{

    NSLog(@"Animation Did stop context = %@",context);
    NSString *direction;
    CGPoint origin;
    CGPoint terminal_origin;

    if (![animationID isEqualToString:@"FORWARD"]){
        origin = CGPointMake(0, 0);
        terminal_origin = CGPointMake(((UILabel*)_textLabel).frame.size.width - self.frame.size.width, ((UILabel*)_textLabel).frame.origin.y);
        direction = @"FORWARD";
    }else{

        terminal_origin = CGPointMake(0, 0);
        origin = CGPointMake(((UILabel*)_textLabel).frame.size.width - self.frame.size.width, ((UILabel*)_textLabel).frame.origin.y);
        direction = @"BACKWARD";
        }

    [self beginAnimationWithOrgigin:origin Terminus:terminal_origin Direction:direction];
}

相关问答

更多
  • 问题在于忘记静态实际上只是普通的C静态变量,它们可以在整个应用程序中全局访问。 (即,未封装在定义它们的范围内。) 同一个类的多个实例都在读取和写入同一个变量的值,从而导致不可预测的行为。 解决方案:传递实例级别消息以控制切换活动,您无法保证您的类是单例。 修改工作代码: - (void)beginAnimationWithOrgigin:(CGPoint)origin Terminus:(CGPoint)terminus Direction:(NSString*)direction{ if (! ...
  • 此代码可能对您有所帮助 [UIView animateWithDuration:0.4 animations:^{ //animation code here` } completion:^(BOOL finished) { //code after animation here }]; This code might help you [UIView animateWithDuration:0.4 animations:^{ //animation code here` } co ...
  • 我想这个问题是因为在你使用touchPoint之前UIView正在改变。 您可以使用临时变量在转换之前保存touchPoint并使用它来显示弹出窗口。 编辑:: 在ViewController的视图上使用UITapGestureRecognizer对象,保持为自定义视图禁用用户交互 但是如果您需要在自定义视图上启用用户交互,那么首先找出与ViewController视图相关的触摸点的位置,并在ViewController的视图中显示弹出窗口。 使用UIGestureRecognizer方法: - (CGPo ...
  • 尝试使用__bridge_retained来保留对象并将其__bridge_retained转换为void* void *context = (__bridge_retained void *)( @1000 ); 然后在animationDidStop您必须使用__bridge_transfer转移所有权。 此时ARC应该自然地释放当前自动释放池中的对象。 - (void)animationDidStop:(void *)context { NSNumber *n = (__bridge_tran ...
  • 第一:Rect为空是因为你使用%@来格式化它,它打印对象,它不是一个对象,它是一个结构体。 如果你想打印出来,使用NSStringFromCGRect(rect)将其转换为字符串,然后打印。 在这一点上没有崩溃的唯一原因是因为x坐标首先存储在结构中,并且等于零,这与空指针相同。 其次,您的原点打印为0,可能是因为您正在使用%d格式化x和y值,这会打印出带符号的十进制整数,但实际上它们是十进制浮点值。 第三:视图的框架不是通过引用返回的。 在您更改矩形后,您必须将其重新分配给视图。 这就是: rect.ori ...
  • 检查您的视图的AutoresizingMask。 将它们设置为UIViewAutoresizingNone进行检查。 我可以将左侧大小调整掩码设置为“调整边距”,结果是IOS大大改变了视图在屏幕外的边距。 您可以通过在旋转后记录视图的帧来检查。 因此,在实例化视图时(在loadView方法上), self.AcTypeView.autoresizingMask = UIViewAutoresizingNone; self.loginView.autoresizingMask = UIViewAutoresi ...
  • 初始双击后,后续单击是否会正确触发动画? 如果是这样,可能是您没有显式初始化BOOL变量,尽管它们应该默认为NO 。 尝试这样做,看看它是否有帮助。 如果您总是需要进行两次点击来制作动画,可以尝试插入一个对运行循环的调用,以查看它是否仅在您的应用程序线程上运行一段时间后处理动画,即它可能只是在处理第二个时click事件是否真的去了并获取任何待处理的动画并执行它们。 该代码将是(在您设置isAnimated并调用commitAnimations ): [[NSRunLoop mainRunLoop] runM ...
  • 我有点像,但View需要从NavigationController : // Push the controller first or the Title doesn't animate NavigationController.PushViewController(controller,false); UIView.BeginAnimations(null,IntPtr.Zero); UIView.SetAnimationDuration(1); UIView.SetAnimationTransitio ...
  • 为什么你不使用它来观看动画? [UIView animateWithDuration:1.0 animations:^{ // place your animations code here }]; 注意:请访问此URL并查看“ 可以动画的内容”部分。 只有很少的属性可以用于动画 https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingVie ...
  • 如果您的动画块发生在另一个动画块中,则-animateWithDuration:animations:将继承外部块的持续时间。 尝试将UIViewAnimationOptionOverrideInheritedDuration添加到选项列表(如果您还需要覆盖曲线,可能还需要UIViewAnimationOptionOverrideInheritedCurve )。 If your animation block is occurring within another animation block, -an ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。