小编sol*_*eil的帖子

检测浏览器是否在Android或iOS设备上运行

我需要在移动网站上更改一些按钮和文本,具体取决于用户是在Android或iOS浏览器上查看它.有可靠的方法来执行检查吗?

html javascript browser jquery

66
推荐指数
3
解决办法
9万
查看次数

带有圆角和边框的 SwiftUI 视图

            ZStack {
                VStack {
                    Text("some text")
                    Button("Ok") {}
                     .foregroundColor(.cyan)
                     .padding()
                }
                .padding()
            }
            .background(.red)
            .border(.blue, width: 5)
            .cornerRadius(20)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我希望整个视图具有带圆角的蓝色边框(而不是与圆形蓝色边框重叠的红色正方形。如何实现?我似乎已经尝试了排序修改器的所有变体。

swift swiftui viewmodifier

64
推荐指数
3
解决办法
5万
查看次数

AVCaptureVideoPreviewLayer方向 - 需要景观

我的应用只是风景.我将这样呈现AVCaptureVideoPreviewLayer:

self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[self.previewLayer setBackgroundColor:[[UIColor blackColor] CGColor]];
[self.previewLayer setVideoGravity:AVLayerVideoGravityResizeAspect];                    
NSLog(@"previewView: %@", self.previewView);
CALayer *rootLayer = [self.previewView layer];
[rootLayer setMasksToBounds:YES];
[self.previewLayer setFrame:[rootLayer bounds]];
    NSLog(@"previewlayer: %f, %f, %f, %f", self.previewLayer.frame.origin.x, self.previewLayer.frame.origin.y, self.previewLayer.frame.size.width, self.previewLayer.frame.size.height);
[rootLayer addSublayer:self.previewLayer];
[session startRunning];
Run Code Online (Sandbox Code Playgroud)

self.previewView的框架为(0,0,568,320),这是正确的.self.previewLayer记录一个(0,0,568,320)的帧,这在理论上是正确的.但是,相机显示在横向屏幕中间显示为纵向矩形,并且相机预览图像的方向错误90度.我究竟做错了什么?我需要相机预览层出现在全屏幕,在横向模式下,图像应正确导向.

avfoundation orientation ios avcapture avcapturesession

56
推荐指数
6
解决办法
5万
查看次数

ios - NSObjCRuntime,NSZone和NSObject中的解析问题

我正在使用AddThis在我的iOS应用中添加共享选项.

我已导入类并将-fno-objc-arc标志添加到所有导入的类中,因为它们不使用ARC.

但是,当我尝试运行应用程序时,我得到了大量的解析问题,例如:

Expected identifier or '('
Unknown type name 'NSString'
Unknown type name 'Protocol'
...
Run Code Online (Sandbox Code Playgroud)

这些错误发生在NSObjCRuntime,NSZone和NSObject中.我也包含必要的框架.有任何想法吗?

如果有帮助,请包括此图片: 图片

compiler-errors addthis ios automatic-ref-counting

39
推荐指数
4
解决办法
2万
查看次数

将JSON转换为.plist

我有一个从Web服务导出的JSON文件.我需要将其转换为.plist文件,我可以将其导入到iOS应用程序的主包中.最简单的方法是什么?

注意 - 应用程序不需要从服务器或任何东西中获取JSON.这是我需要做的一次性转换.该应用程序将始终只使用plist.我只需要知道如何转换它.

json plist ios

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

使用SourceTree克隆存储库

有人可以通过简单地使用SourceTree克隆回购来快速演练吗?

在书签中,我单击克隆存储库.对于源路径,我粘贴了如下所示的URL:

git@codebasehq.com:客户端/应用程序的名字/ IOS-application.git

但我得到"这不是一个有效的源路径/ URL".

我正在代码库中直接从Repository Browser复制,所以我知道URL是正确的.

我还需要做什么?

git github repository atlassian-sourcetree

30
推荐指数
3
解决办法
7万
查看次数

iPhone5(和iPhone6)上的发布屏幕上出现黑条

当iPhone 5首次出现时,我们不得不经历为项目添加Default-568h@2x.png以使应用程序使用iPhone 5的全部高度的愚蠢.在2014年底我们还在做什么?

我们有资产目录和LaunchScreen.xib文件.我们还需要添加Default-568h@2x.png文件吗?如果是这样,它现在在哪里?我尝试了一些不同的东西,我无法摆脱使用Xcode 6 GM创建的新应用程序中的黑条.

ios iphone-5 asset-catalog iphone-6

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

将按钮图像对齐到UIButton的右边缘

关于根据标题文本对齐按钮图像有很多线索,但我找不到任何关于将图像对齐到按钮右侧的信息.

这没有效果:

button.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 50);
Run Code Online (Sandbox Code Playgroud)

如何将图像右键对齐按钮?可以在故事板中完成吗?

xcode uibutton uiimage ios uiedgeinsets

23
推荐指数
8
解决办法
4万
查看次数

Xcode DEBUG模式 - 何时打开/关闭?

我注意到这在dev模式下工作(在模拟器上测试等):

#ifdef DEBUG
    //do stuff
#endif
Run Code Online (Sandbox Code Playgroud)

但是当我存档和分发测试版本时,即使我仍然使用开发人员配置文件构建,该应用程序也不会在DEBUG模式下运行.除非我使用部署配置文件构建并提交给Apple,否则我希望DEBUG模式始终如此.

例如,在发送测试版本时,我不想让人们购买应用内购买,所以我做了类似这样的事情:

- (BOOL)isUpgradePurchased
{
#ifdef DEBUG
    return YES;
#endif

//do the real stuff to determine if purchased and return YES or NO
}
Run Code Online (Sandbox Code Playgroud)

那么我是否还需要为"Release"设置预处理器宏DEBUG = 1?

debugging xcode ios

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

滚动时,UITableView选定的单元格不会保持选中状态

我在滚动表时表格视图单元格没有保持"选中"状态时遇到问题.这是相关代码:

@property (nonatomic, strong) NSIndexPath *selectedIndexPath;

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.selectedIndexPath = indexPath;
    //do other stuff
}

-(UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    MyCustomCell_iPhone* cell = [tableView dequeueReusableCellWithIdentifier:@"MyCustomCell_iPhone"];

    if (cell == nil)
        cell = [[[NSBundle mainBundle] loadNibNamed:@"MyCustomCell_iPhone" owner:self options:nil] objectAtIndex:0];

    if ([indexPath compare: self.selectedIndexPath] == NSOrderedSame) {
        [cell setSelected:YES animated:NO];
    }

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

对于细胞:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    if (selected) {
        self.selectedBg.hidden = NO;
    }else{
        self.selectedBg.hidden = YES;
    }
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{ …
Run Code Online (Sandbox Code Playgroud)

uitableview ios

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