我试图以模糊方式呈现视图控制器,具有透明背景.我的目标是让呈现和呈现的视图控制器视图同时显示.问题是,当呈现动画结束时,呈现视图控制器的视图消失.
- (IBAction)pushModalViewControllerButtonPressed:(id)sender
{
ModalViewController *modalVC = [[ModalViewController alloc] init];
[self presentViewController:modalVC animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以将视图添加为子视图,但出于某种原因我想避免使用此解决方案.我该怎么办呢?
objective-c modalviewcontroller presentmodalviewcontroller ios
如何从iOS中获取用户的当前位置?
我怎样才能找到屏幕上实际可见的显示视图内容的rect(CGRect).
myScrollView.bounds
Run Code Online (Sandbox Code Playgroud)
上面的代码在没有缩放时有效,但只要你允许缩放,它就会以1以外的缩放比例中断.
为了澄清,我想要一个CGRect,它包含相对于内容的滚动视图内容的可见区域.(即如果它是缩放比例2,则矩形的大小将是滚动视图大小的一半,如果它是缩放比例0.5,它将是双倍.)
我正在使用以下代码更改占位符文本颜色,但是当我尝试添加NSFontAttribute时,我得到编译器错误 "too many arguments to method call, expect 2 have 3"
UIColor *color = [UIColor blackColor];
_nameField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Your Name" attributes:@{NSForegroundColorAttributeName: color},@{NSFontAttributeName:@"Roboto-Bold"}];
Run Code Online (Sandbox Code Playgroud)
这工作正常:
UIColor *color = [UIColor blackColor];
_nameField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Your Name" attributes:@{NSForegroundColorAttributeName: color}];
Run Code Online (Sandbox Code Playgroud) 展望创建一个具有它里面的透明框架,使视图背后的意见,可以通过这个透明的框架中可以看出,但是这以外的地区将不显示通过视图.所以在视图中基本上是一个窗口.
希望能够做到这样的事情:
CGRect hole = CGRectMake(100, 100, 250, 250);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor blackColor].CGColor);
CGContextFillRect(context, rect);
CGContextAddRect(context, hole);
CGContextClip(context);
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextFillRect(context, rect);
Run Code Online (Sandbox Code Playgroud)
但是清除不会覆盖黑色,所以整个背景都是黑色的.沿着这些方向的任何想法?
我目前有两个UIViews:一个是红色背景,另一个是蓝色.蓝色视图是红色视图的子视图.我想做的是能够"剪掉"蓝色视图上的矩形,以便可以看到红色视图.你是怎么做的?
当我的应用程序在后台时,我想知道是否可以发送一些webservice调用.skype是如何做到的?即使我按下主页按钮,我的通话也保持连接状态.
我对Objective-C的经验不多.我想使用Swift编程语言隐藏文本字段的键盘.
我也尝试过这个
func textFieldShouldReturn(textField: UITextField!) -> Bool // called when 'return' key pressed. return NO to ignore.
{
return true;
}
Run Code Online (Sandbox Code Playgroud)
但是当我点击返回时,该方法不会被触发.有人有运气吗?
在我的应用程序中,我想向用户呈现一个全屏照片查看器,就像照片应用程序中使用的那样.这仅适用于单张照片,因此应该非常简单.我只是希望用户能够查看这张能够缩放和平移的照片.
我有大部分工作.而且,如果我不将UIImageView作为中心,那么一切都表现得非常完美.但是,当图像被充分缩小时,我真的希望UIImageView在屏幕上居中.我不希望它粘在滚动视图的左上角.
一旦我试图将这个视图居中,我的垂直可滚动区域似乎比它应该更大.因此,一旦我放大一点,我就能够滚动大约100像素超过图像的顶部.我究竟做错了什么?
@interface MyPhotoViewController : UIViewController <UIScrollViewDelegate>
{
UIImage* photo;
UIImageView *imageView;
}
- (id)initWithPhoto:(UIImage *)aPhoto;
@end
@implementation MyPhotoViewController
- (id)initWithPhoto:(UIImage *)aPhoto
{
if (self = [super init])
{
photo = [aPhoto retain];
// Some 3.0 SDK code here to ensure this view has a full-screen
// layout.
}
return self;
}
- (void)dealloc
{
[photo release];
[imageView release];
[super dealloc];
}
- (void)loadView
{
// Set the main view of this UIViewController to be a UIScrollView.
UIScrollView *scrollView …Run Code Online (Sandbox Code Playgroud) 我在XCode中遇到了一些奇怪的链接错误.我或多或少地了解链接错误是什么,而不是为什么它们出现在我的情况中.
我有一个仅作为iPhone启动的应用程序.当我将其调整为通用时,我得到了一些奇怪的链接错误.然后我简单地创建了一个新的通用项目并导入了文件,它构建并执行时没有错误.现在,使用iPad界面,我添加了一些动画并继承了QuartzCore/QuartzCore.h但是当我构建时,我得到了链接错误(如下所示).导致此类问题的原因是,我该如何修复它,以及如何在将来避免它?
"_OBJC_CLASS_$_CAMediaTimingFunction", referenced from:
objc-class-ref-to-CAMediaTimingFunction in mainViewController_iPad.o
"_OBJC_CLASS_$_CABasicAnimation", referenced from:
objc-class-ref-to-CABasicAnimation in mainViewController_iPad.o
"_kCAMediaTimingFunctionEaseIn", referenced from:
_kCAMediaTimingFunctionEaseIn$non_lazy_ptr in mainViewController_iPad.o
(maybe you meant: _kCAMediaTimingFunctionEaseIn$non_lazy_ptr)
"_OBJC_CLASS_$_CAKeyframeAnimation", referenced from:
objc-class-ref-to-CAKeyframeAnimation in mainViewController_iPad.o
"_OBJC_CLASS_$_CAAnimationGroup", referenced from:
objc-class-ref-to-CAAnimationGroup in mainViewController_iPad.o
"_CATransform3DIdentity", referenced from:
_CATransform3DIdentity$non_lazy_ptr in mainViewController_iPad.o
(maybe you meant: _CATransform3DIdentity$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud) ios ×7
objective-c ×7
iphone ×4
uiscrollview ×2
uitextfield ×2
uiview ×2
cgcontext ×1
frameworks ×1
fullscreen ×1
linker ×1
swift ×1
uiimageview ×1
web-services ×1