所以我有一个Date对象,我想创建一个方法,以便它以下列格式打印Date:
11 September 2011, 9:15pm
Run Code Online (Sandbox Code Playgroud)
我怎么做?到目前为止,我只是对日期做了一个toString,它给了我所有GMT信息和我不需要的秒精度.我是否必须使用DateFormatter或者有更简单的方法吗?
编辑后,在标题中包含Java ME,并在发布了原始问题的一些正确答案之后的标签.
所以我有一个UITabBarController应用程序,我想显示一个登录页面,所以我做了:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidLogin:) name:UserDidLoginNotification object:nil];
LoginViewController* loginViewController = [[LoginViewController alloc] init];
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:0];
[self.tabBarController.selectedViewController presentModalViewController:loginViewController animated:NO];
[loginViewController release];
Run Code Online (Sandbox Code Playgroud)
在我的LoginViewController里面,我还可以显示另一个modalViewController:
- (void) twitterLogin: (UIViewController *) askingView
{
UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _twitter delegate: self];
if (controller) {
self.askingView = askingView;
[askingView presentModalViewController: controller animated: YES];
}
}
Run Code Online (Sandbox Code Playgroud)
我有以下方法,其中askView是LoginViewController,当我想解雇这个我做:
[self.askingView dismissModalViewControllerAnimated:YES];
[[NSNotificationCenter defaultCenter] postNotificationName:UserDidLoginNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
但是,这并没有忽略LoginViewController并显示UITabBarController视图..它只是解除了我从LoginvVIewController显示的modalViewController.我在这做错了什么?我也收到以下错误:
attempt to dismiss modal view controller whose view does not currently appear. self = <LoginViewController: 0x2aff70> modalViewController = <SA_OAuthTwitterController: 0x2d2a80>
2011-09-16 …
Run Code Online (Sandbox Code Playgroud) 我尝试过以下方法:
contentScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 600, 400)];
[contentScrollView setContentSize:CGSizeMake(600, 400)];
[contentScrollView addSubview:twitterSigninViewController.view];
[contentScrollView setScrollEnabled:YES];
Run Code Online (Sandbox Code Playgroud)
但是,这不会滚动.为什么是这样?
我有一个UIViewController视图,我想在子视图下面插入:
[self.view insertSubview:ntVC_.view belowSubview:shareView_];
Run Code Online (Sandbox Code Playgroud)
shareView框架Y是959,它的高度是44.所以当这样做时,ntVC框架Y不应该是1004?不过现在是925.任何的想法?
所以我在开源项目中看到了这种方法,当我尝试运行静态分析器时,我只是难以理解为什么这不会泄漏内存.我认为它应该泄漏的原因是因为它分配内存但从未释放它.每次调用方法时它都会释放它(因为= nil).任何人都可以为我照亮吗?
- (BOOL)isValid(NSString *)name
{
// Using a set so access is faster
static NSMutableSet *exp = nil;
// Setup the set once with AB testing info
if (exp == nil) {
exp = [[NSMutableSet alloc] initWithCapacity:5];
}
if (exp != nil) {
return YES;
}
return NO;
}
Run Code Online (Sandbox Code Playgroud) 因此,我尝试通过执行以下操作强制更改部分代码中的设备方向:
if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait ||
[[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown){
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:NO];
}
Run Code Online (Sandbox Code Playgroud)
但方向并没有改变.为什么是这样?基本上目前的方向是肖像,我希望它被迫在景观中
我使用掩码生成了一个圆形UIImage,如下所示(其中masked_circle是黑色圆圈):
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
UIImage *maskImage = [UIImage imageNamed:@"masked_circle.png"];
CGImageRef maskImageRef = [maskImage CGImage];
// create a bitmap graphics context the size of the image
CGContextRef mainViewContentContext = CGBitmapContextCreate (NULL, maskImage.size.width, maskImage.size.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast);
CGFloat ratio = 0;
ratio = maskImage.size.width/ self.image_.size.width;
if(ratio * self.image_.size.height < maskImage.size.height) {
ratio = maskImage.size.height/ self.image_.size.height;
}
CGRect rect1 = {{0, 0}, {maskImage.size.width, maskImage.size.height}};
CGRect rect2 = {{-((self.image_.size.width*ratio)-maskImage.size.width)/2 , -((self.image_.size.height*ratio)-maskImage.size.height)/2}, {self.image_.size.width*ratio, self.image_.size.height*ratio}};
CGContextClipToMask(mainViewContentContext, rect1, maskImageRef);
CGContextDrawImage(mainViewContentContext, rect2, …
Run Code Online (Sandbox Code Playgroud) 我对异步加载和主线程的概念有点困惑.当异步加载某些东西时,它是否意味着它不在主线程上运行?据我所知这是两个不同的概念,可以在主线程上异步运行某些东西,也可以异步在后台/辅助线程上运行.如果我错了,请纠正我.
我有以下css:
.transaction-info {
display: inline-block;
margin-bottom: 20px;
}
.order-info {
padding-left: 150px;
display: inline-block;
margin-bottom: 20px;
}
Run Code Online (Sandbox Code Playgroud)
我想把它合二为一,我该怎么做?
我有以下 html 结构:
<div class="nav-collapse">
<ul class="nav">
</ul>
<ul id="registerCart" class="nav pull-right">
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我只想将以下规则应用于第一个导航,所以我做到了:
.nav-collapse > .nav {
left: 135px;
}
Run Code Online (Sandbox Code Playgroud)
但这也适用于 registerCart。如何仅将其应用于第一个导航?
ipad ×7
iphone ×7
objective-c ×7
ios ×6
css ×2
html ×2
css3 ×1
java ×1
java-me ×1
uiscrollview ×1