在我的应用程序中,我使用了以下视图层次结构:
UIView
----UIScrollView
--------TiledView (UIView subclass, uses CATiledLayer for drawing)
----OverlayView (UIView subclass)
Run Code Online (Sandbox Code Playgroud)
简而言之 - TiledView显示大平铺图像我也将自定义旋转应用于该视图:
tiledView.transform = CGAffineTransformMakeRotation(angle);
Run Code Online (Sandbox Code Playgroud)
TiledView的绘图方法:
- (void)drawRect:(CGRect)rect {
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
...
NSString *fileName = [NSString stringWithFormat:@"tile_%d_%d.jpg", y + 1, x + 1];
UIImage *image = [UIImage imageNamed:fileName];
[image drawInRect:rect];
}
Run Code Online (Sandbox Code Playgroud)
UIScrollView允许滚动和缩放其内容.
叠加视图覆盖UIScrollView,具有透明背景并执行一些自定义绘图.我使用单独的视图来确保线条宽度和字体大小不受滚动视图中缩放比例的影响.
OverlayView的绘图方法:
- (void)drawRect:(CGRect)rect {
// Drawing code
[super drawRect:rect];
// Custom drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 0, 1);
CGContextSetLineWidth(context, lineWidth);
CGContextBeginPath(context);
CGContextMoveToPoint(context, (int)startPoint.x,(int) …Run Code Online (Sandbox Code Playgroud) 编写一个输入数值的程序,然后在循环中逐个输入这些值(双精度型),最后输出它们的和,最大值和最小值.
我为这个作业编写了代码,但是我收到了错误
#include <stdio.h>
int main(void)
{
float a;
float i;
short c;
float sum;
float nu[];
i=nu[];
printf("Number of values :");
scanf("%f",&i);
for (c=1;i>=c;c++)
{
printf("values=");
scanf("%f",&nu[c]);
sum = sum + nu[c];
// printf("Sum = %f\n",sum);
}
printf("sum = %f \n",sum);
// printf("Number of values :");
// scanf("%f",&i);
}
Run Code Online (Sandbox Code Playgroud)
错误是number.c:在函数'main'中:number.c:9:错误:'nu'number.c中缺少数组大小:11:错误:']'令牌之前的预期表达式
我的课
@interface sample:NSObject{
double x;
double y;
}
@property double x;
@property double y;
-(sample *)initWithX: (double)x andY:(double) Y;
@implementation
@synthesize x,y
-(sample *) initWIthX: (double)x andY:(double)y{
self = [super init];
if(self)
{
self.x = x;
self.y = y;
}
return self;
}
-(BOOL)isEqual:(id)other{
if(other == self)
return YES;
if(!other || ![other isKindOfClass:[self class]])
return NO;
return [self isEqualToSample:other];
}
-(BOOL)isEqualToSample:(sample *) other{
if(self == other)
return YES;
if (!([self x] ==[other x]))
return NO;
if (!([self y] ==[other y])) …Run Code Online (Sandbox Code Playgroud) 如何将数据添加到UITableView?我需要在此视图中插入数据数组
UITableView *tableView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStylePlain];
[table numberOfRowsInSection:20];
table.backgroundColor = [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud) 我正在实现一个基于MKMapView的应用程序.在那里我使用自定义图像而不是通过使用MKAnnotationView.Image属性显示一个引脚.它不起作用.它一直显示标准引脚为红色,但不是我指向的图像.有任何想法吗?
- (void)setPin:(MKPinAnnotationView *)aPin forAnnotation:(id <MKAnnotation>)anAnnotation {
if (anAnnotation == self.userAnnotation) {
aPin.image = [UIImage imageNamed:@"youarehere.png"];
aPin.opaque = NO;
aPin.pinColor = MKPinAnnotationColorRed;
}
}
Run Code Online (Sandbox Code Playgroud) 在一个类(名为TimeDetails)中,我需要调用一个方法(类方法),但在编译期间我收到此消息:TimesDetails可能不响应'generateTimeOfPassage',(一个方法调用另一个方法并发送一个NSString对象.这种情况返回nil).
在.h文件中我声明了这样的方法:
+(NSString *)generateTimeOfPassage:(NSString *)_timeString;
Run Code Online (Sandbox Code Playgroud)
在.m文件中:
-(void)initWithTimeData:(NSString *)_timeString{
[super init];
passage=[self generateTimeOfPassage:_timeString]; ---I have the message here...
}
+(NSString *)generateTimeOfPassage:(NSString *)_timeString{
return nil;
}
Run Code Online (Sandbox Code Playgroud)
谢谢 !
马克西姆
我想按升序对多个数字的整数数组进行排序.
这是我的数组:
keyArray:
(
978,
1077,
1067,
1076,
1072,
1082,
1079,
1075,
1071,
1081,
1078,
1080,
1074
Run Code Online (Sandbox Code Playgroud)
)
这是我的代码:
NSSortDescriptor *sortOrder = [NSSortDescriptor sortDescriptorWithKey:@"self" ascending: YES];
NSArray *sortedArray2 = [keyArray sortedArrayUsingComparator:^(id str1, id str2) {
if ([str1 integerValue] < [str2 integerValue]) {
return (NSComparisonResult)NSOrderedDescending;
}
if ([str1 integerValue] > [str2 integerValue]) {
return (NSComparisonResult)NSOrderedAscending;
}
return (NSComparisonResult)NSOrderedSame;
}];
NSLog(@"%@",[keyArray sortedArrayUsingDescriptors: [NSArray arrayWithObject:sortOrder]]);
Run Code Online (Sandbox Code Playgroud)
问题是,这会像这样对数组进行排序
sortedArray: (
1067,
1071,
1072,
1074,
1075,
1076,
1077,
1078,
1079,
1080,
1081,
1082,
978
)
Run Code Online (Sandbox Code Playgroud)
它将首先对四位数字进行排序,然后对三位数字进行排序.
我正在为下面的代码收到这些警告.任何想法如何解决?谢谢你的帮助.
重要的是 "__block mymoviePlayerController = nil;
- (void) moviePlaybackCompleteLightBox:(NSNotification*) notification {
MPMoviePlayerController *mymoviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:mymoviePlayerController];
// movie fadein transition ====================
self.moviePlayerController.view.alpha = 1;
[UIView animateWithDuration:0.3f delay:0.0 options:UIViewAnimationCurveEaseOut
animations:^{
self.moviePlayerController.view.alpha = 0;
}
completion:^(BOOL finished) {
[mymoviePlayerController stop];
[mymoviePlayerController.view removeFromSuperview];
__block mymoviePlayerController = nil;
}];
}
Run Code Online (Sandbox Code Playgroud) 我试图获得正确的电池电量.但是这个值与iphone状态栏中的值不一样.
通过代码使用UIDevice:
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
[[UIDevice currentDevice] batteryLevel];
Run Code Online (Sandbox Code Playgroud)
请有人帮帮我!我需要正确的电池电量,就像在状态栏imdimatery.
我收到一个错误,这个表达太复杂了,无法在合理的时间内解决swift 4任何人都可以帮助我吗?
- AppDelegate.removeGIF(withURL: "images/" + self.currentUID + "/" + self.thisPostId + "." + self.currentGifExt)
Run Code Online (Sandbox Code Playgroud) iphone ×6
objective-c ×5
ios ×3
c ×1
catiledlayer ×1
cocoa-touch ×1
crash ×1
drawing ×1
ios5 ×1
mkannotation ×1
swift ×1
swift4 ×1
uitableview ×1
uiview ×1
xcode ×1
xcode9 ×1