任务:打印数字从1到1000,不使用任何循环或条件语句.不要只写1000次printf()
或cout
语句.
你会怎么用C或C++做到这一点?
在我的诚实意见中,使用CoreGraphics框架是一项繁琐的工作,当涉及到以编程方式绘制PDF文件时.
我想以编程方式创建一个PDF,使用我的应用程序中的视图中的各种对象.
我很想知道iOS SDK是否有任何好的PDF教程,可能是库中的一个下降.
我已经看过这个教程,PDF创建教程,但它主要是用C语言编写的.寻找更多的Objective-C风格.这似乎是一种写入PDF文件的荒谬方式,必须计算线和其他对象的放置位置.
void CreatePDFFile (CGRect pageRect, const char *filename)
{
// This code block sets up our PDF Context so that we can draw to it
CGContextRef pdfContext;
CFStringRef path;
CFURLRef url;
CFMutableDictionaryRef myDictionary = NULL;
// Create a CFString from the filename we provide to this method when we call it
path = CFStringCreateWithCString (NULL, filename,
kCFStringEncodingUTF8);
// Create a CFURL using the CFString we just defined
url = CFURLCreateWithFileSystemPath …
Run Code Online (Sandbox Code Playgroud) 对于我的应用程序所依赖的所有库项目,升级到xcode 4后出现错误.
[BEROR]没有要编译的体系结构(ONLY_ACTIVE_ARCH = YES,活动arch = i386,VALID_ARCHS = armv6).
有没有办法在Xcode 4中进行远程调试?此问题的先前答案是针对Xcode 3和Apple删除了Xcode指南中的特定调试(我假设)涵盖了远程调试.
对于踢球,我一直在这样做lldb
,但如果有一种方法,gdb
那就是伟大的.到目前为止,我已经能够像这样在远程计算机上启动调试服务器
/ usr/bin/ssh -l $ {REMOTE_USER} -f $ {REMOTE_HOST}"/ Developer/usr/bin/debugserver localhost:12345"
然后我可以lldb
从终端手动登录并进行调试.我希望能够做的是至少lldb
在Xcode中启动一个裸会话然后手动启动process connect connect://hostname:port
.
我可以使用以下命令返回屏幕尺寸:
- (void) getScreenResolution {
NSArray *screenArray = [NSScreen screens];
NSScreen *mainScreen = [NSScreen mainScreen];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
{
NSScreen *screen = [screenArray objectAtIndex: index];
NSRect screenRect = [screen visibleFrame];
NSString *mString = ((mainScreen == screen) ? @"Main" : @"not-main");
NSLog(@"Screen #%d (%@) Frame: %@", index, mString, NSStringFromRect(screenRect));
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
屏幕#0(主要)框架:{{0,4},{1344,814}}
有没有一种方法格式化{1344, 814}
来1344x814
?
这非常有效:
- (NSString*) screenResolution {
NSRect screenRect;
NSArray *screenArray …
Run Code Online (Sandbox Code Playgroud) 我需要制作一个UITableViewCell
包含大量文本的内容.我知道我可以添加UITextView
到我的单元格,但每个条目都不会有相同数量的文本.
我知道我可以控制UITableViewCell
with 的高度:-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
,但那不是我想要的.
场景1:
---------------
| First Cell |
---------------
---------------
| Second Cell |
| with some |
| text. |
---------------
---------------
| Third Cell |
---------------
Run Code Online (Sandbox Code Playgroud)
场景2:
---------------
| First Cell |
---------------
---------------
| Second Cell |
| with some |
| more text and |
| an unknown |
| cell height. |
---------------
---------------
| Third Cell |
---------------
Run Code Online (Sandbox Code Playgroud) 我有一个UITabBarController,在初始运行时,我想覆盖登录视图控制器但收到错误.
对<UITabBarController:0x863ae00>的开始/结束外观转换的不平衡调用.
下面是代码.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *lessonVC = [[[LessonViewController alloc] initWithNibName:@"LessonViewController" bundle:nil] autorelease];
UIViewController *programVC = [[[ProgramViewController alloc] initWithNibName:@"ProgramViewController" bundle:nil] autorelease];
UIViewController *flashcardVC = [[[FlashCardViewController alloc] initWithNibName:@"FlashCardViewController" bundle:nil] autorelease];
UIViewController *moreVC = [[[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil] autorelease];
UINavigationController *lessonNVC = [[[UINavigationController alloc] initWithRootViewController:lessonVC] autorelease];
UINavigationController *programNVC = [[[UINavigationController alloc] initWithRootViewController:programVC] autorelease];
UINavigationController …
Run Code Online (Sandbox Code Playgroud) 我有一台配备Mac OS X Snow Leopard的Mac,我可以添加iOS 5.1吗?
随着iPad 3的新分辨率,我们将如何处理图像,因为如果应用程序将在iPhone 3GS,4和iPad 3中运行,我认为我们应该有3个不同名称的图像,如@ 3x.png或..谢谢.
从iOS 3.2开始,MPMoviePlayerController类允许在视图层次结构中嵌入电影.现在我面临这个问题:我通过放置一个MPMoviePlayerController实例来创建我的纵向视图.当用户触摸"全屏"按钮时,此视图以全屏模式进入,但视图仍保持纵向.当用户旋转设备时,全屏电影视图不会自动旋转,因为我的应用禁止横向界面方向.因此,为了允许电影播放器全屏视图的自动旋转,我改变了我的视图控制器shouldAutorotateToInterfaceOrientation:方法如果 - 并且仅当 - 电影播放器处于全屏模式时返回YES.这非常有效:当用户全屏进入然后旋转到横向时,播放器会自动旋转到横向并填充整个屏幕.
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
if(UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
return(YES);
}
if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
return([movieController isFullscreen]);
}
return(NO);
}
Run Code Online (Sandbox Code Playgroud)
现在,当我在全景视图中触摸"完成"按钮的同时保持横向状态时,会出现问题.全屏关闭,然后我看到的是我的原始视图自动旋转:但我不希望这种自动旋转.
部分但不可接受的解决方案是侦听"MPMoviePlayerDidExitFullscreenNotification",如果界面旋转为横向,则强制重定向以使用未记录的私有函数:
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait]
Run Code Online (Sandbox Code Playgroud)
这有效但不可接受,因为禁止使用此方法.
我试图强制使用方向,[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]
但因为我在Tab栏中这不起作用(UITabBar仍然是横向大小).
谢谢你的帮助
我想对UIImageView
缩放,旋转进行2次操作,我有2个问题:
答:我为ex做了缩放操作.当我尝试进行旋转时,将
UIImageView
其设置为初始大小,我想知道如何保持缩放UIImageView
并从缩放图像进行旋转.B.我想将缩放操作与旋转相结合,我不知道如何实现这一点:
- (void)viewDidLoad
{
foo = [[UIImageView alloc]initWithFrame:CGRectMake(100.0, 100.0, 600, 800.0)];
foo.userInteractionEnabled = YES;
foo.multipleTouchEnabled = YES;
foo.image = [UIImage imageNamed:@"earth.jpg"];
foo.contentMode = UIViewContentModeScaleAspectFit;
foo.clipsToBounds = YES;
[self.view addSubview:foo];
}
//---pinch gesture---
UIPinchGestureRecognizer *pinchGesture =
[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
[foo addGestureRecognizer:pinchGesture];
[pinchGesture release];
//---rotate gesture---
UIRotationGestureRecognizer *rotateGesture =
[[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotateGesture:)];
[foo addGestureRecognizer:rotateGesture];
[rotateGesture release];
//---handle pinch gesture---
-(IBAction) handlePinchGesture:(UIGestureRecognizer *) sender {
NSLog(@"Pinch");
CGFloat factor = [(UIPinchGestureRecognizer *) …
Run Code Online (Sandbox Code Playgroud) iphone ×5
ios ×4
ipad ×3
xcode ×3
c ×1
c++ ×1
cocoa ×1
debugging ×1
lldb ×1
macos ×1
objective-c ×1
pinch ×1
printf ×1
resolution ×1
rotation ×1
screen ×1
transitions ×1
uiimageview ×1
uitableview ×1
uitextview ×1
xcode4 ×1
zoom ×1