小编Bri*_*yle的帖子

Android ViewPager - 在左侧和右侧显示页面预览

我正在使用Android ViewPager.我想要做的是在左侧和右侧显示页面的预览.我已经看到我可以使用负片pageMargin来显示右侧的预览.

setPageMargin(-100);
Run Code Online (Sandbox Code Playgroud)

无论如何我还能展示左侧的预览吗?它基本上类似于我正在寻找的画廊小部件.

android android-viewpager

99
推荐指数
9
解决办法
5万
查看次数

iOS - 动画效果 - 图像弹出

我想在我的iphone应用程序中"弹出"一个图像,而不是只是出现.通过"pop-in"我的意思是它会从一个小点增长到它的实际大小.作为参考,这与Keynote中的"pop"动画效果完全相同.我对iOS动画完全不熟悉,所以如果有人能指出我需要使用的动画效果的方向,我将非常感激.

谢谢

布赖恩

更新 我从下面的建议中添加了此代码.这可以工作,但它可以缩小我的图像,而不是向上.我知道这是因为我有0.01作为变换比例尺寸,但我想知道如何开始使用大小为0.0的图像并将其缩放到1.只需将图像的大小设置为0?谢谢

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.2];
image.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

iphone animation uianimation ios

31
推荐指数
2
解决办法
3万
查看次数

iOS - UIBarButtonItem - 后退按钮标题垂直位置未调整

我正在UIBarButtonItem使用我的对象设置自定义字体UIAppearance.这很好,并正确设置字体.但是,我需要调整按钮标题的垂直位置以适应新字体的大小.

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIFont fontWithName:@"Sketch Rockwell" size:12] forKey:UITextAttributeFont] forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, 1.5) forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)

问题是标题的垂直位置在常规中正确调整UIBarButtonItem,但导航栏上的后退按钮无法调整.我假设我的目标是我的代码中的正确对象,因为它的字体更新,而不是它的标题的垂直位置.

有没有人知道如何直接定位后退按钮?

谢谢

布赖恩

back-button uibarbuttonitem ios

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

iOS - UITapGestureRecognizer - 带参数的选择器

在我的应用中,我在运行时动态地将图像添加到我的视图中.我可以同时在屏幕上显示多个图像.每个图像都是从一个对象加载的.我在图像中添加了一个tapGestureRecongnizer,以便在点击它时调用相应的方法.

    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
    [plantImageView addGestureRecognizer:tapGesture];
Run Code Online (Sandbox Code Playgroud)

我的问题是我不知道我拍了什么图像.我知道我可以调用tapGestureRecognizer.location来获取屏幕上的位置,但这对我来说并不是很好.理想情况下,我希望能够将加载图像的对象传递到点击手势.但是,似乎我只能传递选择器名称"imageTapped:"而不是它的参数.

- (IBAction)imageTapped:(Plant *)plant
{
   [self performSegueWithIdentifier:@"viewPlantDetail" sender:plant];
}
Run Code Online (Sandbox Code Playgroud)

有没有人知道我可以将我的对象作为参数传递给tapGestureRecongnizer的方式或者我可以处理它的任何其他方式?

谢谢

布赖恩

iphone selector ios uitapgesturerecognizer

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

Xcode Analyzer - 忽略CocoaPods目标

我有一个使用CocoaPods设置的Xcode工作区.当我在我的项目上运行Xcode的Analyzer时,它会分析我自己的源代码以及Pods目标中的所有源代码.这引发了许多我不感兴趣的警告,因为我只想看到我自己的源代码的分析器警告.

我从pod的构建目标中取消选中"Analyze"但这似乎没有任何效果.

有没有办法在运行分析器时忽略Pods目标?

在此输入图像描述

xcode clang-static-analyzer ios cocoapods

14
推荐指数
2
解决办法
1952
查看次数

Cocoapods - 指定来源回购用户名

使用Cocoapods v0.34.4

我的Podfile包含以下内容

source 'https://bitbucket.org/MyRepo/My-podspecs.git'
source 'https://github.com/CocoaPods/Specs.git'
Run Code Online (Sandbox Code Playgroud)

当我运行pod安装时,我需要为我的bitbucket帐户指定用户名/密码.当我在本地运行的,但是我也跑这个作为持续集成的一部分,建立与服务器的XCode和的XCode 6.在XCode的服务器,这是好的吊舱安装,因为它不能没有我的凭据访问到位桶命令失败.

是否可以将我的凭据添加到Podfile或任何其他方式告诉Cocoapods bitbucket源代码库的凭据?

xcode bitbucket ios cocoapods xcode-server

8
推荐指数
1
解决办法
4957
查看次数

iOS - 关闭WiFi的地理围栏

我的代码在我的iPhone上创建了一个地理围栏,它会在调用didExitRegion时触发一些代码.但是,我发现当我关闭WiFi时,didExitRegion永远不会被触发.是否需要WiFi来监控iOS上的区域变化?我想要的准确度设置为kCLLocationAccuracyHundredMeters.我正在测试iOS 6.1和iPhone 4.

以下是我设置位置监控的代码:

- (id)init {
self = [super init];
if (self) {
    CLLocationManager *manager = [[CLLocationManager alloc] init];
    manager.delegate = self;
    manager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
    manager.distanceFilter = RADIUS/10.0;
    manager.headingFilter = kCLHeadingFilterNone;
    self.locationManager = manager;
    self.authorizationStatus = [CLLocationManager authorizationStatus];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)

谢谢

iphone geolocation wifi ios geofencing

6
推荐指数
1
解决办法
6097
查看次数

iOS - UiTableviewCell - 背景图像一次仅显示在一个单元格上

我已经使用UIAppearance在我的应用程序中设置表格单元格的背景图像.

[[UITableViewCell appearance] setBackgroundView:[ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"list_bg.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]];
Run Code Online (Sandbox Code Playgroud)

但是,当我查看列表时,仅为屏幕上的一个单元格设置背景图像.如果我滚动屏幕,背景图像将设置在出现在视图中的单元格上,但它不会在任何其他可见单元格上设置此bg图像.

任何人都知道发生了什么事吗?我认为通过设置UITableviewCell的UIAppearance,这种类型的所有实例都会自动获取背景图像.

谢谢

布赖恩

这是我的cellForRowAtIndexPath方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"plantCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"PlantListCell" owner:self options:nil];
    cell = _plantCell;
    self.plantCell = nil;
}


Plant *plant = [self.fetchedResultsController objectAtIndexPath:indexPath];

UIImageView *thumbnail = (UIImageView *)[cell viewWithTag:1];
thumbnail.image = [UIImage imageNamed:[plant.name stringByAppendingString:@"_S"]];

UILabel *label = (UILabel *)[cell viewWithTag:2];
label.text = plant.name;

UIImageView *set = (UIImageView …
Run Code Online (Sandbox Code Playgroud)

iphone background-image uitableview ios

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

iOS - 执行一段代码10秒钟

我想每500毫秒执行一段代码,总共10秒钟.我用这段代码每半秒执行一次代码

[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(getLevel:) userInfo:nil repeats: YES];
Run Code Online (Sandbox Code Playgroud)

但我似乎无法弄清楚如何在10秒后停止执行."重复"参数似乎不允许指定的时间.有人能指出我应该去哪里的方向吗?

谢谢Brian

objective-c nstimer ios

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