本文介绍了当当前时间等于iPhone中指定的时间时如何发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我是iPhone应用程序开发的新手.

我正在创建一个发送短信的应用程序.

在我的应用程序中,我需要在指定的时间发送短信.

我有一个时间选择器,可以在UITextField中指定时间.


Hi everyone., i''m new to iphone application development.

i''m creating a application to send sms.

In my application i need to send sms on specified time.

I have a time picker to specify the time in UITextField.


-(void)sendInAppSMS
{
    NSLog(@"SendMessage");

    if([textFieldRounded.text isEqualToString:@""] || [textFieldRounded1.text isEqualToString:@""] || [textFieldRounded2.text isEqualToString:@""] || [textFieldRounded.text isEqualToString:@"(null)"] ||  [textFieldRounded1.text isEqualToString:@"(null)"] ||  [textFieldRounded1.text isEqualToString:@"(null)"] || [textFieldRounded.text isEqualToString:nil]  || [textFieldRounded1.text isEqualToString:nil]|| [textFieldRounded2.text isEqualToString:nil])
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"SMS" message:@"Please Enter All Fields!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
        [alert show];
    }
    else
    {
        NSLog(@"Done");
        NSDateFormatter *SentTime = [[NSDateFormatter alloc] init];
        [SentTime setDateFormat:@"dd/MM/YYYY hh:mm aa"];
        NSDate *now1 = [NSDate date];
        NSString *Time1 = [SentTime stringFromDate:now1];
        NSLog(@"Time is :%@",Time1);
        NSString *Sentime=[NSString stringWithFormat:@"%@",textFieldRounded2.text];

        if([Sentime isEqualToString:Time1])
        {
            NSLog(@"Time Matching... can send msg now");

            MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
            if([MFMessageComposeViewController canSendText])
            {

                NSString *Message = [NSString stringWithFormat:@"%@, %@",textFieldRounded1.text,textFieldRounded2.text];
                NSLog(@"Message is %@", Message);
                controller.body = Message;
                controller.recipients = [NSArray arrayWithObjects:@"+919994442409" , nil];
                controller.messageComposeDelegate = self;
                [self presentModalViewController:controller animated:YES];
            }

        }
        else
        {
            NSLog(@"Send Message when time reach at %@",textFieldRounded2.text);

            //What code i should write here to store this message and to send on that specified time
        }
    }
}




如果时间等于当前时间,则立即发送短信(无需将消息存储在任何地方).

否则,当当前时间变为指定时间时,我需要发送该短信.直到时间到了如何保存(存储)消息并继续发送.






if the time is equal to current time then send the sms nowitself (no need to store the messsage anywhere).

Other wise i need to send that sms , when current time becomes as that specified time. Until the time reach how to keep(store) the message and send on the time.



推荐答案

<Window.Resources>
        <Storyboard x:Key="Storyboard1" RepeatBehavior="Forever" AutoReverse="True">
            <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="regularPolygon">
                <EasingPointKeyFrame KeyTime="0" Value="0.5,0.5">
                    <EasingPointKeyFrame.EasingFunction>
                        <BackEase EasingMode="EaseInOut"/>
                    </EasingPointKeyFrame.EasingFunction>
                </EasingPointKeyFrame>
                <EasingPointKeyFrame KeyTime="0:0:0.8" Value="0.5,0.5"/>
            </PointAnimationUsingKeyFrames>
            <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="image">
                <EasingPointKeyFrame KeyTime="0:0:0.8" Value="0.5,0.5"/>
            </PointAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="image">
                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="500"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="regularPolygon">
                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="500"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Storyboard2">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="image2">
                <EasingDoubleKeyFrame KeyTime="0" Value="-30"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="image2">
                <EasingDoubleKeyFrame KeyTime="0" Value="-4"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="image2">
                <EasingDoubleKeyFrame KeyTime="0" Value="0.583"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0.5"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.15"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.4" Value="2"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="image2">
                <EasingDoubleKeyFrame KeyTime="0" Value="0.738"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1.54"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0.77"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.231"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.4" Value="2"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

    </Window.Resources>


<Grid>
    <Canvas Name="cans" Margin="0,-10,0,10">
            <Image x:Name ="image" Margin="0,0,524,354" Source="taddy1.jpg" Stretch="Uniform" Width="100" >
            <Image.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </Image.RenderTransform>
        </Image>
        <ed:RegularPolygon x:Name="regularPolygon" Fill="#FFF5F5F4" HorizontalAlignment="Left" Height="32" InnerRadius="0.47211" Margin="72,8,0,0" PointCount="5" Stretch="Fill" Stroke="Black" VerticalAlignment="Top" Width="14">
            <ed:RegularPolygon.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform/>
                    <TranslateTransform/>
                </TransformGroup>
            </ed:RegularPolygon.RenderTransform>
        </ed:RegularPolygon>
        <Image Name ="image1" Source="Arrow.jpg" Stretch="Uniform" Height="19" Canvas.Left="19" Canvas.Top="240">

         </Image>
<Slider Name="silde" Minimum="0" Maximum="550" SmallChange="5" ValueChanged="Slider_ValueChanged_1" Height="16" Width="604" Canvas.Top="416" Canvas.Left="10" />
<Image Name="imgball" Height="41" Canvas.Left="10" Source="ball3d.png" Stretch="Fill" Canvas.Top="370" Width="37"/>

    <Button Name="btntime" Canvas.Left="589" BorderThickness="0" Width="40" Height="40" Background="#FF629FC1"  IsEnabled="True" >
                <Button.Effect>
                    <DropShadowEffect ShadowDepth="10" BlurRadius="50"/>
                </Button.Effect>


            </Button>
    <Image x:Name="image2" Visibility="Collapsed" Height="61" Canvas.Left="264" Source="heart.jpg" Stretch="Fill" Canvas.Top="205" Width="96" RenderTransformOrigin="0.5,0.5">
        <Image.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </Image.RenderTransform>
    </Image>
    <TextBlock Height="0" Canvas.Left="216" TextWrapping="Wrap" Text="TextBlock" Canvas.Top="202" Width="8"/>






        </Canvas>
</Grid>
</Window>


这篇关于当当前时间等于iPhone中指定的时间时如何发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 04:30