小编Nir*_*iya的帖子

iOS 7.0中的水平CAGradientLayer

在我的应用程序中,我使用a CAGradientLayer来设置我的单元格的背景,这样:

retValue = [tableView dequeueReusableCellWithIdentifier:@"Cells" forIndexPath:indexPath];
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor blueColor];
bgColorView.layer.masksToBounds = YES;
id startColor = (id)[[UIColor colorWithWhite:0.75 alpha:1] CGColor];
id endColor = (id)[[UIColor blueColor] CGColor];
CAGradientLayer* gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = retValue.contentView.bounds;
gradientLayer.colors = @[startColor,startColor,endColor,endColor];
gradientLayer.locations = @[[NSNumber numberWithFloat:0],
    [NSNumber numberWithFloat:0.95],
    [NSNumber numberWithFloat:0.95],
    [NSNumber numberWithFloat:1]];
[gradientLayer setStartPoint:CGPointMake(0,0.5)];
[gradientLayer setEndPoint:CGPointMake(1,0.5)];
[bgColorView.layer addSublayer:gradientLayer];
retValue.selectedBackgroundView = bgColorView;
Run Code Online (Sandbox Code Playgroud)

(此代码在里面- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath)

它在iOS 6上工作正常但在iOS 7上不起作用,在新的iOS中,渐变始终是垂直的(忽略startPoint和endPoint)

有没有人在同一个问题上遇到过?

谢谢,

佩里

ios cagradientlayer

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

UITableViewCell上的UIPanGestureRecognizer会覆盖UITableView的滚动视图手势识别器

我已经分类了UITableViewCell,在那个课程中我应用了一个Pan手势识别器:

UIPanGestureRecognizer *panning = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePanning:)];
panning.minimumNumberOfTouches = 1;
panning.maximumNumberOfTouches = 1;
[self.contentView addGestureRecognizer:panning];
[panning release];
Run Code Online (Sandbox Code Playgroud)

然后,我实现了委托协议,该协议应该允许在表的视图中同时进行手势:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

然后我在handlePanning方法中放置一个日志,看看它何时被检测到:

- (void)handlePanning:(UIPanGestureRecognizer *)sender {
    NSLog(@"PAN");
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我无法垂直滚动查看tableview中的单元格列表,handlePanning无论我在哪个方向上调用它都会被调用.

我想要的handlePanning只是在只有水平平移而不是垂直时调用.会很感激一些指导.

cocoa-touch uigesturerecognizer ios

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

如何在ios中的UIAlertView上以普通字体显示所有按钮文本

在我的iOSproject中,我有一个UIAlertView带有3个按钮,但最后一个按钮文本默认为粗体字体,如此...,如何将第三个按钮文本的字体样式设置为正常? 在此输入图像描述

以下是用于创建该警报视图的代码

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"test" message:@"testTestTest" delegate:Nil cancelButtonTitle:nil otherButtonTitles:@"first",@"second",@"third" ,nil];
    [alert show];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uialertview ios

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

“ipa build”从命令行传递但在Jenkins(深圳Xcode iOS应用程序)上失败

我正在通过命令行从 MyApp.xcodeproj 构建一个 MyApp.ipa 并且构建成功。我正在使用深圳ruby gem 从命令行构建应用程序。然而,构建在 Jenkins 中失败,并出现以下错误:

*** error: Couldn't codesign /Users/administrator/Library/Developer/Xcode/DerivedData///////MyApp.app/Frameworks/libswiftCore.dylib: codesign failed with exit code 1
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-stdlib-tool failed with exit code 1

** ARCHIVE FAILED **
Run Code Online (Sandbox Code Playgroud)

以下构建命令失败:

CopySwiftLibs /Users/administrator/Library/Developer/Xcode/DerivedData///////MyApp.app
Run Code Online (Sandbox Code Playgroud)

我怀疑该错误与项目签名有关。目前我正在通过命令行使用XSigning对其进行签名,并且它在本地 MacOS 机器上从命令行成功构建。但是,当我通过 Jenkins 运行完全相同的命令时,它失败了。

请帮忙。

xcode command-line ios jenkins ipa

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

如何在swift中处理推送通知?

我有一个ios应用程序,我使用apns发送推送.我需要处理推送消息,如果正确则显示消息.我怎样才能迅速实现它?这是我的代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:
    [NSObject: AnyObject]?) -> Bool {
    registerForPushNotifications(application)
    return true
}

func registerForPushNotifications(application: UIApplication) {
    let notificationSettings = UIUserNotificationSettings(
        forTypes: [.Badge, .Sound, .Alert], categories: nil)
    application.registerUserNotificationSettings(notificationSettings)
}

func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
    if notificationSettings.types != .None {
        application.registerForRemoteNotifications()
    }
}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
    var tokenString = ""

    for i in 0..<deviceToken.length {
        tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
    }

    print("Device Token:", tokenString)
}

func application(application: UIApplication, …
Run Code Online (Sandbox Code Playgroud)

cocoa apple-push-notifications ios swift

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

使用UIModalPresentationOverFullScreen更改UIStatusbarStyle

我目前UIModalPresenationOverFullScreen用来呈现下一个控制器,此刻我想改变它UIStatusBarStyle.以前的控制器已经得到了UIStatusBarStyleDefault但我想要使用的电流UIStatusBarStyleLightContent.

因为UIModalPresenationOverFullScreen之前的控制器仍然在后台运行.这导致了当前将继承该样式的问题.

在plist文件中,我设置View controller-based status bar appearance为YES,并尝试了一些提示,例如:

[self setNeedsStatusBarAppearanceUpdate];
self.navigationController.navigationBar.barStyle =UIStatusBarStyleLightContent;
- (UIStatusBarStyle)preferredStatusBarStyle { 
      return UIStatusBarStyleLightContent; 
}
Run Code Online (Sandbox Code Playgroud)

Nothings似乎有效.任何遇到同样问题的人.我仍然希望以前的控制器存活但是改变了UIStatusBarstyle.

xcode statusbar uinavigationcontroller ios uimodalpresentationstyle

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

tkinter'NonType'对象没有属性'pack'(仍然有效?)

我是Python的新手,刚刚开始使用tkinter.运行下面的代码我得到一个属性错误but1.pack()(NoneType对象没有属性pack).但据我所知,这个错误对窗口的功能没有任何影响,它仍然pack是按钮.窗口仍然出现,所有按钮都按预期运行.

搜索我可以看到其他人有这个错误,但没有给出的答案解决了我的问题.希望你能提供帮助.

代码:

import tkinter
import ctypes
lst=[]

user32 = ctypes.windll.user32
screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)

def closewindow():
    window.destroy()
def btn1():
    lst.append("Button1")
def btn2():
    lst.append("Button2")

window = tkinter.Tk()

size = str(screensize[0])+'x'+str(screensize[1])
window.geometry(size)

but1 = tkinter.Button(window, text="Button1", command=btn1).grid(column = 1, row = 1)
but2 = tkinter.Button(window, text="Button2", command=btn2).grid(column = 2, row = 1)
ext = tkinter.Button(window, text="Stop", command=closewindow).grid(column = 3, row = 1)

but1.pack()
but2.pack()
ext.pack()

window.mainloop()
Run Code Online (Sandbox Code Playgroud)

回调;

Traceback (most recent call last):
  File …
Run Code Online (Sandbox Code Playgroud)

python windows windows-xp tkinter python-3.x

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

Shell脚本:十六进制循环

我正在尝试学习shell脚本并编写一个简单的脚本来增加循环中的Hex值.

这是我的脚本:

increment=0x0001
handle=0x0001

for((i=1;i<=20;i++))
do
   echo $handle
   handle=$(($handle + $increment))
   handle=$(printf '%x' $handle)
done
Run Code Online (Sandbox Code Playgroud)

这是我的输出:

0x0001
2
3
4
5
6
7
8
9
a
1
2
3
4
5
6
7
8
9
a
Run Code Online (Sandbox Code Playgroud)

它工作正常,直到第10次迭代,但之后再次从1开始.

谁能让我知道我的错误?

编辑:删除handle=$(printf '%x' $handle)行输出后:

0x0001
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Run Code Online (Sandbox Code Playgroud)

实际上我只想在HEX中输出.

linux bash shell

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

这些陈述中的复制,保留和分配有什么区别?

我试图了解以下四种情况的内存管理之间的区别:

@implementation ABC

-(void) fun1 
{
   ObjectA * obj1 = [[ObjectA alloc] init];
   ObjectA * obj2 = obj1;
}

-(void) fun2 
{
   ObjectA * obj1 = [[ObjectA alloc] init];
   ObjectA * obj2 = [obj1 retain];
}

-(void) fun3 
{
   ObjectA * obj1 = [[ObjectA alloc] init];
   ObjectA * obj2 = [obj1 copy];
}

-(void) fun4
{
   ObjectA * obj1 = [[ObjectA alloc] init];
   ObjectA * obj2 = [obj1 mutableCopy];
}

@end
Run Code Online (Sandbox Code Playgroud)

我咨询过这个问题,但我仍然不清楚上述每个问题之间的区别.有人可以解释每个人做了什么,以及他们为什么不同?

cocoa objective-c ios

-3
推荐指数
1
解决办法
2871
查看次数